Scopira 20080306

sidekickthread.h

00001 
00002 /*
00003  *  Copyright (c) 2005    National Research Council
00004  *
00005  *  All rights reserved.
00006  *
00007  *  This material is confidential and proprietary information of
00008  *  National Research Council Canada ("Confidential Information").
00009  *  This Confidential Information may only be used and reproduced
00010  *  in accordance with the terms of the license agreement.
00011  *
00012  */
00013 
00014 #ifndef __INCLUDED_SCOPIRA_CORE_SIDEKICKTHREAD_H__
00015 #define __INCLUDED_SCOPIRA_CORE_SIDEKICKTHREAD_H__
00016 
00017 #include <list>
00018 
00019 #include <scopira/core/sidekick.h>
00020 
00021 namespace scopira
00022 {
00023   namespace core
00024   {
00025     class sidekick_runner;
00026     class sidekick_thread;
00027   }
00028 }
00029 
00038 class scopira::core::sidekick_runner : public virtual scopira::tool::runnable_i,
00039     public scopira::core::sidekick_queue_i
00040 {
00041   public:
00043     SCOPIRA_EXPORT sidekick_runner(void);
00044 
00046     SCOPIRA_EXPORT virtual void run(void);
00047 
00049     SCOPIRA_EXPORT virtual void notify_stop(void);
00050 
00051   protected:
00052     SCOPIRA_EXPORT virtual void enqueue_sidekick(sidekick_i *t);
00053     SCOPIRA_EXPORT virtual bool is_sidekick_running(void);
00054 
00055   private:
00056     typedef std::list<scopira::tool::count_ptr<sidekick_i> > sidekick_list;
00057 
00058     // the condition in dm_openwindows is used as the signal for this area
00059     struct sidekick_area {
00060       bool alive;
00061       bool running;
00062       sidekick_list queue;
00063     };
00064 
00065     scopira::tool::event_area<sidekick_area> dm_sidekickarea;
00066 };
00067 
00075 class scopira::core::sidekick_thread
00076 {
00077   public:
00079     SCOPIRA_EXPORT sidekick_thread(void);
00081     SCOPIRA_EXPORT ~sidekick_thread();
00082 
00083   private:
00084     sidekick_runner dm_runner;
00085     scopira::tool::thread dm_thready;
00086 };
00087 
00088 #endif
00089