llrun.h

Go to the documentation of this file.
00001 
00034 #ifndef LL_LLRUN_H
00035 #define LL_LLRUN_H
00036 
00037 #include <vector>
00038 #include <boost/shared_ptr.hpp>
00039 
00040 class LLRunnable;
00041 
00050 class LLRunner
00051 {
00052 public:
00056         typedef boost::shared_ptr<LLRunnable> run_ptr_t;
00057 
00061         typedef S64 run_handle_t;
00062 
00066         LLRunner();
00067 
00071         ~LLRunner();
00072 
00076         enum ERunSchedule
00077         {
00078                 // The runnable will run in N seconds
00079                 RUN_IN,
00080 
00081                 // The run every N seconds
00082                 RUN_EVERY,
00083 
00084                 // A count of the run types
00085                 RUN_SCHEDULE_COUNT
00086         };
00087 
00093         S32 run();
00094 
00106         run_handle_t addRunnable(
00107                 run_ptr_t runnable,
00108                 ERunSchedule schedule,
00109                 F64 seconds);
00110         
00118         run_ptr_t removeRunnable(run_handle_t handle);
00119 
00120 protected:
00121         struct LLRunInfo
00122         {
00123                 run_handle_t mHandle;
00124                 run_ptr_t mRunnable;
00125                 ERunSchedule mSchedule;
00126                 F64 mNextRunAt;
00127                 F64 mIncrement;
00128                 LLRunInfo(
00129                         run_handle_t handle,
00130                         run_ptr_t runnable,
00131                         ERunSchedule schedule,
00132                         F64 next_run_at,
00133                         F64 increment);
00134         };
00135         typedef std::vector<LLRunInfo> run_list_t;
00136         run_list_t mRunOnce;
00137         run_list_t mRunEvery;
00138         run_handle_t mNextHandle;
00139 };
00140 
00141 
00151 class LLRunnable
00152 {
00153 public:
00154         LLRunnable();
00155         virtual ~LLRunnable();
00156 
00164         virtual void run(LLRunner* runner, S64 handle) = 0;
00165 };
00166 
00167 #endif // LL_LLRUN_H

Generated on Thu Jul 1 06:09:05 2010 for Second Life Viewer by  doxygen 1.4.7