From 18f2016b1f743068cd3d4bb9740845c2d55af3f3 Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Tue, 20 Mar 2007 10:41:14 +0000 Subject: Removed the Fl::set_awake_cb API and documented the Fl::awake(function, data) API. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@5749 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- documentation/Fl.html | 24 +++++++++++++++++------- documentation/advanced.html | 25 +++++++++++++------------ 2 files changed, 30 insertions(+), 19 deletions(-) (limited to 'documentation') diff --git a/documentation/Fl.html b/documentation/Fl.html index 24d5be118..77ff43336 100644 --- a/documentation/Fl.html +++ b/documentation/Fl.html @@ -126,7 +126,6 @@ state information and global methods for the current application.

  • selection_owner
  • set_abort
  • set_atclose
  • -
  • set_awake_cb
  • set_boxtype
  • set_color
  • set_font
  • @@ -391,9 +390,24 @@ argument on the command-line. You can change the message by setting the

    void awake(void *p);

    -

    The awake() method 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. +

    int awake(void (*callback)(void*), void *userdata);

    -

    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. Use the Fl::set_awake_cb() function to register your own thread message handler that is called for every message received by the main thread. +

    The awake() method 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. + +

    The second form of awake() registers a function that will be +called by the main thread during the next message handling cycle. +awake() will return 0 if the callback function was registered, +and -1 if registration failed. Over a thousand awake callbacks can be +registered simultaneously.

    See also: multithreading. @@ -1169,10 +1183,6 @@ of this.

    void set_atclose(void (*f)(Fl_Window*,void*));

    -

    void set_awake_cb(void (*cb)(void*));

    - -

    Sets a function to handle thread messages sent via the Fl::awake() function.

    -

    void set_boxtype(Fl_Boxtype, Fl_Box_Draw_F*,uchar,uchar,uchar,uchar);
    void set_boxtype(Fl_Boxtype, Fl_Boxtype from);

    diff --git a/documentation/advanced.html b/documentation/advanced.html index f7623435b..774a75ccd 100644 --- a/documentation/advanced.html +++ b/documentation/advanced.html @@ -31,7 +31,8 @@ that will help you to get the most out of FLTK.

    You can now start as many threads as you like. From within a thread (other than the main thread) FLTK calls must be wrapped -with calls to Fl::lock() and Fl::unlock(): +with calls to Fl::lock() +and Fl::unlock():

         Fl::lock();      // avoid conflicting calls
    @@ -39,27 +40,28 @@ with calls to Fl::lock() and Fl::awake(msg):

    +

    You can send messages from child threads to the main thread +using Fl::awake(msg):

         void *msg;       // "msg" is a pointer to your message
         Fl::awake(msg);  // send "msg" to main thread
     
    -

    These messages can be read by the main thread using Fl::thread_message() or by registering a message callback with Fl::set_awake_cb():

    +

    You can also tell the main thread to call a function for you +as soon as possible by using +Fl::awake(callback, userdata):

    -    void message_cb(void *msg) {
    -      ... do something with "msg" ...
    +    void do_something(void *userdata) {
    +      // running with the main thread
         }
     
    -    int main() {
    -      Fl::lock();
    -      Fl::set_awake_cb(message_cb);
    -      /* run thread */
    -      return (Fl::run());
    -    }
    +    // running in another thread
    +    void *data;       // "data" is a pointer to your user data
    +    Fl::awake(do_something, data);  // call something in main thread
     
    +

    FLTK supports multiple platforms, some of them which do not allow any other but the main thread to handle system events and @@ -86,7 +88,6 @@ related methods that will handle system messages

    See also: void awake(void *message), void lock(), -void set_awake_cb(void (*cb)(void *), void *thread_message(), void unlock(). -- cgit v1.2.3