网络服务器软件开发/中间件开发,关注ACE/ICE/boost

C++博客 首页 新随笔 联系 聚合 管理
  152 Posts :: 3 Stories :: 172 Comments :: 0 Trackbacks

#include "ace/Task.h"
#include <ace/Manual_Event.h>
#include <ace/Auto_Event.h>
#include "ace/OS.h"
#include <ace/Date_Time.h>
#include <iostream>

using namespace std;
#pragma comment(lib,"aced")

/**
* if MANUAL reset
*    sleep till the event becomes signaled
*    event remains signaled after wait() completes.
* else AUTO reset
*    sleep till the event becomes signaled
*    event resets wait() completes.
*/
//ACE_Manual_Event mevent;
ACE_Auto_Event   auto_event;
class TaskTest : public ACE_Task_Base
{
public:
 int svc()
 {
  cout << "task base test" << endl;
  ACE_Date_Time dt;
  cout << "y = " << dt.year() << endl;
  cout << "m = " << dt.month() << endl;
  cout << "s = " << dt.second() << endl;
  ACE_OS::sleep(2);
  //mevent.signal();
  auto_event.signal();
  return 0;
 }
protected:
private:
};
int main(int argc, char* argv[])
{
 TaskTest tt;
 tt.activate();
 //mevent.wait();
 auto_event.wait();
 tt.wait();
 return 0;
}

posted on 2008-04-13 16:32 true 阅读(1045) 评论(0)  编辑 收藏 引用 所属分类: ACE

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理