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

FX::FXWorker Class Reference

An FXWorker is a transient thread that performs an FXRunnable task. More...

#include <FXWorker.h>

Inheritance diagram for FX::FXWorker:
FX::FXThread FX::FXRunnable

Public Member Functions

 FXWorker (FXRunnable *task=nullptr)
 Create worker for runnable.
 
void setRunnable (FXRunnable *task)
 Change runnable if not started yet.
 
FXRunnablegetRunnable () const
 Return runnable.
 
virtual FXint run ()
 Run worker.
 
virtual ~FXWorker ()
 Destroy.
 
- 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 ~FXRunnable ()
 Destroy a runnable.
 

Static Public Member Functions

static FXWorkerexecute (FXRunnable *task, FXuval stacksize=0)
 Create and start a worker on a given runnable.
 
- 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.
 

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...
 

Detailed Description

An FXWorker is a transient thread that performs an FXRunnable task.

After the worker thread finishes the execution of the task, the worker thread's memory is automatically reclaimed. The FXRunnable itself is not deleted; it will thus outlive the worker that runs it. Any exceptions raised by the task are caught by the worker thread, and will be rethrown after the worker thread's memory has been reclaimed.


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

Copyright © 1997-2022 Jeroen van der Zijp