handle_timeout.inl

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

INL
87
字号
/* -*- C++ -*- */// $Id: Handle_Timeout.inl 74999 2006-10-24 23:06:58Z ossama $#include "ace/Service_Config.h"#include "ace/Get_Opt.h"#include "ace/OS_NS_stdio.h"#include "ace/OS_NS_string.h"ACE_INLINEHandle_Timeout::Handle_Timeout (void): count (0){}ACE_INLINE intHandle_Timeout::info (ACE_TCHAR **strp, size_t length) const{  ACE_TCHAR buf[BUFSIZ];  ACE_OS::strcpy (buf, ACE_TEXT("# tests timeout facility\n"));  if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0)    return -1;  else    ACE_OS::strncpy (*strp, buf, length);  return ACE_OS::strlen (buf);}ACE_INLINE intHandle_Timeout::init (int argc, ACE_TCHAR *argv[]){  ACE_Time_Value delta (10);  ACE_Time_Value interval (1);  ACE_Get_Opt    get_opt (argc, argv, ACE_TEXT("a:d:i:"), 0);  intptr_t       arg = 0;  for (int c; (c = get_opt ()) != -1; )     switch (c)       {       case 'd':         delta.sec (ACE_OS::atoi (get_opt.opt_arg ()));         break;       case 'i':         interval.sec (ACE_OS::atoi (get_opt.opt_arg ()));         break;       case 'a':         arg = ACE_OS::atoi (get_opt.opt_arg ());         break;       default:         break;       }  if (ACE_Reactor::instance ()->schedule_timer (this,                                                reinterpret_cast<void *> (arg),                                                delta,                                                interval) == -1)    return -1;  else    return 0;}ACE_INLINE intHandle_Timeout::fini (void){  return 0;}ACE_INLINE ACE_HANDLEHandle_Timeout::get_handle (void) const{  return ACE_INVALID_HANDLE;}ACE_INLINE intHandle_Timeout::handle_timeout (const ACE_Time_Value &tv,                                const void *arg){  if (this->count++ >= 10)    return -1; // Automatically cancel periodic timer...  // Cast arg to a long, first, because a pointer is the same  // size as a long on all current ACE platforms.  ACE_DEBUG ((LM_INFO,              ACE_TEXT ("time for this(%u) expired at (%d, %d) with arg = %d\n"),             this, tv.sec (), tv.usec (), (int) (long) arg));  return 0;}

⌨️ 快捷键说明

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