Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

RunnableRunner.h

Go to the documentation of this file.
00001 #ifndef RUNNABLERUNNER_H 00002 #define RUNNABLERUNNER_H 00003 00004 #include "Exceptions.h" 00005 #include "Runnable.h" 00006 #include "PtMutex.h" 00007 00008 /* 00009 Provides for the one-time running of a Runnable. 00010 00011 NOTE: THIS CLASS IS NOT SAFE FOR CONCURRENT METHOD INVOCATIONS. 00012 */ 00013 00014 BOREALIS_NAMESPACE_BEGIN; 00015 00016 class RunnableRunner 00017 { 00018 public: 00019 // Launches the specified runnable in a new thread. 00020 RunnableRunner(Runnable & aRunnable) 00021 throw (std::exception); 00022 00023 virtual ~RunnableRunner(); 00024 00025 // Gets the address of the Runnable that was most recently supplied to 00026 // the start(...) method. 00027 // Raises an exception if the start(...) method hasn't been called yet. 00028 Runnable * getRunnable() 00029 throw (std::exception); 00030 00031 // Waits for the currently executing Runnable to return from its run() method. 00032 // Raises an exception if start(...) hasn't been called yet, or if join() has 00033 // already been called since the last execution of a Runnable. 00034 void join() 00035 throw (std::exception); 00036 00037 private: 00038 RunnableRunner(const RunnableRunner & rhs); 00039 RunnableRunner & operator= (const RunnableRunner & rhs); 00040 00041 static void *threadFunc(void *pRunnableRunner); 00042 00043 PtMutex _mtx; 00044 Runnable * _pRunnable; 00045 bool _joinCalled; 00046 pthread_t _tid; 00047 }; 00048 00049 BOREALIS_NAMESPACE_END; 00050 00051 #endif

Generated on Fri Nov 12 15:15:22 2004 for Borealis by doxygen 1.3.8