Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FX::FXScopedThread Class Reference

FXScopedThread is a kind of thread which automatically performs a thread join to clean up the thread when going out of scope. More...

#include <FXScopedThread.h>

Inheritance diagram for FX::FXScopedThread:
FX::FXThread FX::FXRunnable

Public Member Functions

 FXScopedThread ()
 Initialize thread object.
 
virtual ~FXScopedThread ()
 Destroy thread after joining it.
 
- Public Member Functions inherited from FX::FXThread
 FXThread ()
 Initialize thread object.
 
FXThreadID id () const
 Return handle of this thread object. More...
 
FXbool running () const
 Return true if this thread is running.
 
FXbool start (FXuval stacksize=0)
 Start thread; the thread is started as attached. More...
 
FXbool join ()
 Suspend calling thread until thread is done. More...
 
FXbool join (FXint &code)
 Suspend calling thread until thread is done, and set code to the return value of run() or the argument passed into exit(). More...
 
FXbool cancel ()
 Cancel the thread, stopping it immediately, running or not. More...
 
FXbool detach ()
 Detach thread, so that a no join() is necessary to harvest the resources of this thread. More...
 
FXbool priority (Priority prio)
 Set thread scheduling priority.
 
Priority priority () const
 Return thread scheduling priority.
 
FXbool policy (Policy plcy)
 Set thread scheduling policy.
 
Policy policy () const
 Get thread scheduling policy.
 
FXbool affinity (FXulong mask)
 Change thread's processor affinity, the set of processors onto which the thread may be scheduled.
 
FXulong affinity () const
 Get thread's processor affinity.
 
FXbool description (const FXString &desc)
 Change thread description.
 
FXString description () const
 Return thread description, if any.
 
FXbool suspend ()
 Suspend thread; return true if success.
 
FXbool resume ()
 Resume thread; return true if success.
 
virtual ~FXThread ()
 Destroy the thread immediately, running or not. More...
 
- Public Member Functions inherited from FX::FXRunnable
 FXRunnable ()
 Construct a runnable.
 
virtual FXint run ()=0
 Subclasses should overload this function to perform actual work.
 
virtual ~FXRunnable ()
 Destroy a runnable.
 

Additional Inherited Members

- Public Types inherited from FX::FXThread
enum  Priority {
  PriorityError =-1, PriorityDefault, PriorityMinimum, PriorityLower,
  PriorityMedium, PriorityHigher, PriorityMaximum
}
 Thread priority levels. More...
 
enum  Policy { PolicyError =-1, PolicyDefault, PolicyFifo, PolicyRoundRobin }
 Thread scheduling policies. More...
 
- Static Public Member Functions inherited from FX::FXThread
static void exit (FXint code=0)
 Exit the calling thread. More...
 
static void yield ()
 Make the thread yield its time quantum.
 
static void pause ()
 Processor pause/back-off.
 
static FXTime time ()
 Return time in nanoseconds since Epoch (Jan 1, 1970).
 
static FXTime steadytime ()
 Get steady time in nanoseconds since some arbitrary start time.
 
static FXTime ticks ()
 Return time in processor ticks.
 
static void sleep (FXTime nsec)
 Make the calling thread sleep for a number of nanoseconds.
 
static void wakeat (FXTime nsec)
 Wake at appointed time specified in nanoseconds since Epoch.
 
static FXThreadself ()
 Return pointer to the FXThread instance associated with the calling thread; it returns NULL for the main thread and all threads not created by FOX.
 
static FXThreadID current ()
 Return thread id of calling thread.
 
static FXint processors ()
 Return number of available processors (cores) in the system.
 
static FXint processor ()
 Return processor index of the calling thread; returns a value between [0 ... More...
 
static FXThreadStorageKey createStorageKey ()
 Generate new thread local storage key.
 
static void deleteStorageKey (FXThreadStorageKey key)
 Dispose of thread local storage key.
 
static void * getStorage (FXThreadStorageKey key)
 Get thread local storage pointer using key.
 
static void setStorage (FXThreadStorageKey key, void *ptr)
 Set thread local storage pointer using key.
 

Detailed Description

FXScopedThread is a kind of thread which automatically performs a thread join to clean up the thread when going out of scope.

Scoped Threads should not be detached, as this would prevent a successful join(). Note that Scoped Thread does not forcibly terminate the thread, and thus allows the thread function run() to conclude gracefully; calling thread waits inside join() until thread is done.


The documentation for this class was generated from the following file:

Copyright © 1997-2022 Jeroen van der Zijp