demux_posix_timer_queue.hpp

00001 #line 848 "./lpsrc/flx_demux.pak"
00002 #ifndef __POSIX_TIMER_QUEUE__
00003 #define __POSIX_TIMER_QUEUE__
00004 
00005 #include "pthread_thread.hpp"  // flx_thread_t
00006 #include "pthread_mutex.hpp"  // flx_mutex_t
00007 #include "pthread_condv.hpp"  // flx_condv_t
00008 #include "demux_timer_queue.hpp" // base class
00009 #include <sys/time.h>        // timespecs, gettimeofday
00010 
00011 namespace flx { namespace demux {
00012 
00013 // looks like a worker queue, but couldn't quite mash it into one
00014 class DEMUX_EXTERN posix_timer_queue : public timer_queue
00015 {
00016     flx::pthread::flx_mutex_t lock; // factor to prio queue?
00017     flx::pthread::flx_condv_t sleep_cond;
00018     flx::pthread::flx_thread_t sleep_thread;
00019     void*        opaque_prio_queue;        // less fat
00020 
00021     static void* thread_start(void*);    // passed "this"
00022     bool thread_loop_body();
00023 
00024 
00025     void wakeup_thread();                // we can do this!
00026 
00027     void add_sleep_request(sleep_task* st, timespec* abs);
00028 public:
00029     posix_timer_queue();
00030     ~posix_timer_queue();
00031 
00032     // thread safe.
00033     virtual void add_sleep_request(sleep_task* st, double delta);
00034 
00035     // in seconds, relative to same base as timer::get_time.
00036     virtual void add_abs_sleep_request(sleep_task* st, double when);
00037 };
00038 
00039 }}
00040 
00041 #endif // __POSIX_TIMER_QUEUE__
00042 

Generated on Mon Dec 11 18:08:29 2006 for Felix by  doxygen 1.5.1