ctimer.cc
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <ctimer.hxx>
00021
00022 namespace control {
00023
00024 ctimer::ctimer(const std::string& nameid, const sigc::slot< bool >& exec_hook): ccontrol(nameid, sigc::mem_fun<bool>(this, &ccontrol::noop) )
00025 {
00026 _state = ::control::pause;
00027 init();
00028 }
00029
00030
00031 ctimer::ctimer(): ccontrol()
00032 {
00033 init();
00034 }
00035
00036
00037 ctimer::~ctimer()
00038 {
00039 }
00040
00041
00042
00043
00044
00048 bool ctimer::pause()
00049 {
00050 _state = ::control::pause;
00051 return true;
00052 }
00053
00054
00058 bool ctimer::start( unsigned long delay, bool once)
00059 {
00060 _duration = delay;
00061 _state = ::control::proceed;
00062 _single_shot = once;
00063 return ccontrol::start();
00064 }
00065
00066
00070 bool ctimer::resume()
00071 {
00072 _state = control::proceed;
00073 ccontrol::signal();
00074 return true;
00075 }
00076
00077
00081 void ctimer::stop()
00082 {
00083 _state = ::control::pause;
00084 }
00085
00086
00090 bool ctimer::controller_loop()
00091 {
00092 do{
00093 switch(_state){
00094 case ::control::proceed:
00095 usleep( _duration );
00096 cthread::notify();
00097 if( _single_shot) stop();
00098 break;
00099 case ::control::terminate:
00100 return false;
00101 case ::control::pause:
00102 do wait(); while(_state == ::control::pause );
00103 break;
00104 }
00105 }while(_state != ::control::terminate );
00106 return true;
00107 }
00108
00109
00110 }
API Documentation Generated by:
1.4.0
About the author |

Site started with trial version of DreamWeaver MX 2004 |
Finalizing with

|
Contact | ©2005, Serge Lussier ( Bretzel )