exithandler.cpp

来自「ace开发环境 用来开发网络程序 其运用了设计模式、多平台、C++等多种知识」· C++ 代码 · 共 72 行

CPP
72
字号
// $Id: ExitHandler.cpp 55034 2004-01-01 21:01:01Z shuston $// Listing 1 code/ch13#include "ace/Task.h"#include "ace/Log_Msg.h"class ExitHandler : public ACE_At_Thread_Exit{public:  virtual void apply (void)  {    ACE_DEBUG ((LM_INFO, ACE_TEXT ("(%t) is exiting \n")));    // Shut down all devices.  }};// Listing 1// Listing 2 code/ch13class HA_CommandHandler : public ACE_Task_Base{public:  HA_CommandHandler(ExitHandler& eh) : eh_(eh)  { }  virtual int svc (void)  {    ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) starting up \n")));    this->thr_mgr ()->at_exit (eh_);    // Do something.    // Forcefully exit.    ACE_Thread::exit ();    // NOT REACHED    return 0;  }private:  ExitHandler& eh_;};// Listing 2// Listing 3 code/ch13int ACE_TMAIN (int, ACE_TCHAR *[]){  ExitHandler eh;  HA_CommandHandler handler (eh);  handler.activate ();  ACE_Thread_Manager::instance ()->wait ();  return 0;}// Listing 3#if 0// Listing 4 code/ch13int ACE_TMAIN (int, ACE_TCHAR *[]){  ExitHandler eh;  ACE_Thread_Manager tm;  HA_CommandHandler handler (eh);  handler.thr_mgr (&tm);  handler.activate ();  tm.wait();  return 0;}// Listing 4#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?