FLTK 1.3.4
Multithreading support functions

fl multithreading support functions declared in <FL/Fl.H> More...

Functions

static void Fl::awake (void *message=0)
 Sends a message pointer to the main thread, causing any pending Fl::wait() call to terminate so that the main thread can retrieve the message and any pending redraws can be processed. More...
 
static int Fl::awake (Fl_Awake_Handler cb, void *message=0)
 See void awake(void* message=0). More...
 
static int Fl::lock ()
 The lock() method blocks the current thread until it can safely access FLTK widgets and data. More...
 
static void * Fl::thread_message ()
 The thread_message() method returns the last message that was sent from a child by the awake() method. More...
 
static void Fl::unlock ()
 The unlock() method releases the lock that was set using the lock() method. More...
 

Detailed Description

fl multithreading support functions declared in <FL/Fl.H>

Function Documentation

void Fl::awake ( void *  msg = 0)
static

Sends a message pointer to the main thread, causing any pending Fl::wait() call to terminate so that the main thread can retrieve the message and any pending redraws can be processed.

Multiple calls to Fl::awake() will queue multiple pointers for the main thread to process, up to a system-defined (typically several thousand) depth. The default message handler saves the last message which can be accessed using the Fl::thread_message() function.

In the context of a threaded application, a call to Fl::awake() with no argument will trigger event loop handling in the main thread. Since it is not possible to call Fl::flush() from a subsidiary thread, Fl::awake() is the best (and only, really) substitute.

See also: Multithreading

int Fl::awake ( Fl_Awake_Handler  func,
void *  data = 0 
)
static

See void awake(void* message=0).

Let the main thread know an update is pending and have it call a specific function.

Registers a function that will be called by the main thread during the next message handling cycle. Returns 0 if the callback function was registered, and -1 if registration failed. Over a thousand awake callbacks can be registered simultaneously.

See Also
Fl::awake(void* message=0)
int Fl::lock ( )
static

The lock() method blocks the current thread until it can safely access FLTK widgets and data.

Child threads should call this method prior to updating any widgets or accessing data. The main thread must call lock() to initialize the threading support in FLTK. lock() will return non-zero if threading is not available on the platform.

Child threads must call unlock() when they are done accessing FLTK.

When the wait() method is waiting for input or timeouts, child threads are given access to FLTK. Similarly, when the main thread needs to do processing, it will wait until all child threads have called unlock() before processing additional data.

Returns
0 if threading is available on the platform; non-zero otherwise.

See also: Multithreading

void * Fl::thread_message ( )
static

The thread_message() method returns the last message that was sent from a child by the awake() method.

See also: Multithreading

void Fl::unlock ( )
static

The unlock() method releases the lock that was set using the lock() method.

Child threads should call this method as soon as they are finished accessing FLTK.

See also: Multithreading