2014-11-19 00:25:21 +08:00
# pragma once
# include "acl_cpp/acl_cpp_define.hpp"
# include <list>
namespace acl
{
class event_task ;
class ACL_CPP_API event_timer
{
public :
/**
* <EFBFBD> <EFBFBD> <EFBFBD> 캯 <EFBFBD> <EFBFBD>
* @ param keep { bool } <EFBFBD> ö <EFBFBD> ʱ <EFBFBD> <EFBFBD> <EFBFBD> Ƿ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Զ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
*/
event_timer ( bool keep = false ) ;
virtual ~ event_timer ( ) ;
/**
* <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʱ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϊ <EFBFBD> <EFBFBD> ʱ <EFBFBD> Ļ ص <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
* <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͷ ţ <EFBFBD> һ <EFBFBD> <EFBFBD> <EFBFBD> ú <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ã <EFBFBD>
* <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ζ <EFBFBD> Ÿ ö <EFBFBD> ʱ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> е <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ж <EFBFBD> ʱ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
* <EFBFBD> <EFBFBD> ʱ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> б <EFBFBD> ɾ <EFBFBD> <EFBFBD>
* <EFBFBD> ú <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
* 1 ) <EFBFBD> <EFBFBD> ʱ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> е <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϊ 0 ʱ
* 2 ) <EFBFBD> <EFBFBD> û <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ظ <EFBFBD> <EFBFBD> <EFBFBD> ʱ <EFBFBD> <EFBFBD> <EFBFBD> Ҹ ö <EFBFBD> ʱ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> һ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʱ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
* 3 ) <EFBFBD> <EFBFBD> del_timer ( event_timer * ) <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ú <EFBFBD>
*/
virtual void destroy ( void ) { }
/**
* <EFBFBD> <EFBFBD> ʱ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ƿ <EFBFBD> Ϊ <EFBFBD> <EFBFBD>
* @ return { bool }
*/
bool empty ( void ) const
{
return tasks_ . empty ( ) ;
}
/**
* <EFBFBD> <EFBFBD> ʱ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
* @ return { size_t }
*/
size_t length ( void ) const
{
return length_ ;
}
/**
* <EFBFBD> ö <EFBFBD> ʱ <EFBFBD> <EFBFBD> <EFBFBD> Ƿ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Զ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
* @ param on { bool }
*/
void keep_timer ( bool on ) ;
/**
* <EFBFBD> ж ϸ ö <EFBFBD> ʱ <EFBFBD> <EFBFBD> <EFBFBD> Ƿ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Զ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
* @ return { bool }
*/
bool keep_timer ( void ) const
{
return keep_ ;
}
/**
* <EFBFBD> <EFBFBD> <EFBFBD> ն <EFBFBD> ʱ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ķ <EFBFBD> ʱ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
* @ return { int } <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ķ <EFBFBD> ʱ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ĸ <EFBFBD> <EFBFBD> <EFBFBD>
*/
int clear ( void ) ;
/**
* <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʵ <EFBFBD> ִ ˻ ص <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ע <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ߽ <EFBFBD> ֹ <EFBFBD> <EFBFBD>
* timer_callback <EFBFBD> ڲ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> event_timer <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
* <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ɴ <EFBFBD> <EFBFBD> <EFBFBD>
* @ param id { unsigned int } <EFBFBD> <EFBFBD> Ӧ ij <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ID <EFBFBD> <EFBFBD>
*/
virtual void timer_callback ( unsigned int id ) = 0 ;
/****************************************************************/
/* <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ե<EFBFBD> <D4B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> º<EFBFBD> <C2BA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> һ Щ<D2BB> µĶ<C2B5> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ID <20> <> */
/****************************************************************/
# ifdef WIN32
/**
* <EFBFBD> <EFBFBD> <EFBFBD> Ա <EFBFBD> <EFBFBD> <EFBFBD> ʱ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> µ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ID <EFBFBD> ţ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͨ <EFBFBD> <EFBFBD> һ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʱ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
* <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʱ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
* @ param id { unsigned int } <EFBFBD> <EFBFBD> ʱ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʱ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ID <EFBFBD> <EFBFBD>
* @ param delay { __int64 } ÿ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Զ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ö <EFBFBD> ʱ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͬ ʱ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ӧ <EFBFBD> Ķ <EFBFBD> ʱ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʱ
* <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ID <EFBFBD> Ŵ <EFBFBD> <EFBFBD> <EFBFBD> ( <EFBFBD> 뼶 )
* @ return { __int64 } <EFBFBD> <EFBFBD> <EFBFBD> 뱾 <EFBFBD> <EFBFBD> ʱ <EFBFBD> <EFBFBD> <EFBFBD> ĵ <EFBFBD> һ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ᴥ <EFBFBD> <EFBFBD> <EFBFBD> Ķ <EFBFBD> ʱ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ID <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ( <EFBFBD> 뼶 )
*/
__int64 set_task ( unsigned int id , __int64 delay ) ;
/**
* ɾ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʱ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ij <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ ID <EFBFBD> <EFBFBD> Ӧ <EFBFBD> Ķ <EFBFBD> ʱ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
* @ param { unsigned int } <EFBFBD> <EFBFBD> ʱ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ID
* @ return { __int64 } <EFBFBD> <EFBFBD> <EFBFBD> 뱾 <EFBFBD> <EFBFBD> ʱ <EFBFBD> <EFBFBD> <EFBFBD> ĵ <EFBFBD> һ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ᴥ <EFBFBD> <EFBFBD> <EFBFBD> Ķ <EFBFBD> ʱ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ID <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ( <EFBFBD> 뼶 )
*/
__int64 del_task ( unsigned int id ) ;
# else
long long int set_task ( unsigned int id , long long int delay ) ;
long long int del_task ( unsigned int id ) ;
# endif
//////////////////////////////////////////////////////////////////////
/**
* <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> е <EFBFBD> ʱ <EFBFBD> Ķ <EFBFBD> ʱ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
* @ return { long lont int } <EFBFBD> <EFBFBD> һ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ҫ <EFBFBD> <EFBFBD> ʱ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
*/
# ifdef WIN32
__int64 trigger ( void ) ;
__int64 min_delay ( void ) const
{
return min_delay_ ;
}
# else
long long int trigger ( void ) ;
long long int min_delay ( void ) const
{
return min_delay_ ;
}
# endif
protected :
# ifdef WIN32
__int64 min_delay_ ;
__int64 present_ ;
# else
long long int min_delay_ ;
long long int present_ ;
# endif
private :
size_t length_ ;
std : : list < event_task * > tasks_ ;
bool keep_ ; // <20> ö<EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> Ƿ<EFBFBD> <C7B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Զ<EFBFBD> <D4B6> <EFBFBD> <EFBFBD> <EFBFBD>
# ifdef WIN32
__int64 set_task ( event_task * task ) ;
# else
long long int set_task ( event_task * task ) ;
# endif
/**
* <EFBFBD> <EFBFBD> <EFBFBD> õ <EFBFBD> ǰ <EFBFBD> <EFBFBD> ʱ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʱ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
*/
void set_time ( void ) ;
} ;
} // namespace acl