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/advanced.html | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'documentation/advanced.html') 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