INTRODUCTION Overview Download and Install Documentation Publications REPOSITORY Libraries DEVELOPER Dev Guide Dashboard PEOPLE Contributors Users Project Download Mailing lists
|
gbxiceutilacfr::Thread Class ReferenceA minor extention of the IceUtil::Thread class. More...
Inherits gbxutilacfr::Stoppable. Inherited by gbxiceutilacfr::SafeThread, TestThread, TestThreadWithExit, TestThreadWithNap, TestThreadWithThrow, and TestThreadWithWait.
Detailed DescriptionA minor extention of the IceUtil::Thread class.Adds an option to stop a thread with stop(). Requires that the thread periodically checks whether it has to stop by calling isStopping(); Since stop() is public, it can be called from inside or outside of the derived class. To use this class, simply overload the virtual IceUtil::Thread::run() function. void MyThread::run() { // initialize // main loop while ( !isStopping() ) { // do something } // clean up } The implicit state machine of this class has 4 states {Starting, Running, Stopping, Stopped}. Events and the corresponding state transitions are listed below. Note that the final state may only be accessed when using smart pointer gbxiceutilacfr::ThreadPtr (otherwise the thread self-destructs).
EVENT : Constructor IceUtil::Thread::Thread() TRANSITION : Starting INTERNAL : isStopping()=false, isAlive()=false, isStarted()=false EVENT : IceUtil::Thread::start() TRANSITION : Starting -> Running INTERNAL : isStopping()=false, isAlive()=true, isStarted()=true EVENT : gbxiceutilacfr::Thread::stop() TRANSITION : Running -> Stopping INTERNAL : isStopping()=true, isAlive()=true, isStarted()=true EVENT : termination of run() function. TRANSITION : Stopping -> Stopped INTERNAL : isStopping()=true, isAlive()=false, isStarted()=true Caveats:
Member Function Documentation
Depricated function! Use isStopping() instead (note that it returns the opposite). Returns FALSE if thread was told to stop, TRUE otherwise. References isStopping().
Lets the thread know that it's time to stop. Thread-safe, so it can be called from inside or outside this thread. Referenced by gbxiceutilacfr::stop(), and gbxiceutilacfr::stopAndJoin().
Wait for someone from the outside to call stop. It may be necessary to call this function before exitting from IceUtil::Thread::run after catching an exception. If we just exit from run() and someone calls our stop() function afterwards there's a possibility of lock up. References isStopping(). Referenced by gbxiceutilacfr::SafeThread::run().
The documentation for this class was generated from the following files:
|