diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2007-03-20 10:41:14 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2007-03-20 10:41:14 +0000 |
| commit | 18f2016b1f743068cd3d4bb9740845c2d55af3f3 (patch) | |
| tree | bd0e16fdb0e630d2e7ab8d6846dfba423dadd47b /documentation | |
| parent | 27568cfa1c948ba536e03519372b38412adec756 (diff) | |
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
Diffstat (limited to 'documentation')
| -rw-r--r-- | documentation/Fl.html | 24 | ||||
| -rw-r--r-- | documentation/advanced.html | 25 |
2 files changed, 30 insertions, 19 deletions
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.</P> <LI><A HREF="#Fl.selection_owner">selection_owner</A></LI> <LI><A HREF="#Fl.set_abort">set_abort</A></LI> <LI><A HREF="#Fl.set_atclose">set_atclose</A></LI> - <LI><A HREF="#Fl.set_awake_cb">set_awake_cb</A></LI> <LI><A HREF="#Fl.set_boxtype">set_boxtype</A></LI> <LI><A HREF="#Fl.set_color">set_color</A></LI> <LI><A HREF="#Fl.set_font">set_font</A></LI> @@ -391,9 +390,24 @@ argument on the command-line. You can change the message by setting the <H4><A NAME="Fl.awake">void awake(void *p);</A></H4> -<P>The <TT>awake()</TT> method sends a message pointer to the main thread, causing any pending <A HREF="#Fl.wait"><TT>Fl::wait()</TT></A> call to terminate so that the main thread can retrieve the message and any pending redraws can be processed. +<H4><A NAME="Fl.awake">int awake(void (*callback)(void*), void *userdata);</A></H4> -<P>Multiple calls to <TT>Fl::awake()</TT> 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 <A HREF="#Fl.thread_message"><TT>Fl::thread_message()</TT></A> function. Use the <A HREF="#Fl.set_awake_cb"><TT>Fl::set_awake_cb()</TT></A> function to register your own thread message handler that is called for every message received by the main thread. +<P>The <TT>awake()</TT> method sends a message pointer to the main thread, +causing any pending <A HREF="#Fl.wait"><TT>Fl::wait()</TT></A> call to +terminate so that the main thread can retrieve the message and any pending +redraws can be processed. + +<P>Multiple calls to <TT>Fl::awake()</TT> 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 <A HREF="#Fl.thread_message"> +<TT>Fl::thread_message()</TT></A> function. + +<P>The second form of <TT>awake()</TT> registers a function that will be +called by the main thread during the next message handling cycle. +<TT>awake()</TT> will return 0 if the callback function was registered, +and -1 if registration failed. Over a thousand awake callbacks can be +registered simultaneously. <P>See also: <a href="advanced.html#multithreading">multithreading</a>. @@ -1169,10 +1183,6 @@ of this.</I> <H4><A NAME="Fl.set_atclose">void set_atclose(void (*f)(Fl_Window*,void*));</A></H4> -<H4><A NAME="Fl.set_awake_cb">void set_awake_cb(void (*cb)(void*));</A></H4> - -<P>Sets a function to handle thread messages sent via the <A HREF="#Fl.awake"><TT>Fl::awake()</TT></A> function.</P> - <H4><A NAME="Fl.set_boxtype">void set_boxtype(Fl_Boxtype, Fl_Box_Draw_F*,uchar,uchar,uchar,uchar);<BR> void set_boxtype(Fl_Boxtype, Fl_Boxtype from);</A></H4> 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.</P> <P>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 <a href="Fl.html#Fl.lock"><tt>Fl::lock()</tt></a> and <a href="Fl.html#Fl.unlock"><tt>Fl::unlock()</tt></a>: +with calls to <a href="Fl.html#Fl.lock"><tt>Fl::lock()</tt></a> +and <a href="Fl.html#Fl.unlock"><tt>Fl::unlock()</tt></a>: <pre> Fl::lock(); // avoid conflicting calls @@ -39,27 +40,28 @@ with calls to <a href="Fl.html#Fl.lock"><tt>Fl::lock()</tt></a> and <a href="Fl. Fl::unlock(); // allow other threads to access FLTK again </pre> -<p>You can send messages from child threads to the main thread using <a href="Fl.html#Fl.awake"><tt>Fl::awake(msg)</tt></a>:</p> +<p>You can send messages from child threads to the main thread +using <a href="Fl.html#Fl.awake"><tt>Fl::awake(msg)</tt></a>:</p> <pre> void *msg; // "msg" is a pointer to your message Fl::awake(msg); // send "msg" to main thread </pre> -<p>These messages can be read by the main thread using <A HREF="Fl.html#Fl.thread_message"><TT>Fl::thread_message()</TT></A> or by registering a message callback with <A HREF="Fl.html#Fl.set_awake_cb"><TT>Fl::set_awake_cb()</TT></A>:</p> +<p>You can also tell the main thread to call a function for you +as soon as possible by using +<a href="Fl.html#Fl.awake"><tt>Fl::awake(callback, userdata)</tt></a>:</p> <pre> - 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 </pre> + <P>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</li> <P>See also: <a href="Fl.html#Fl.awake">void awake(void *message)</A>, <a href="Fl.html#Fl.lock">void lock()</A>, -<a href="Fl.html#Fl.set_awake_cb">void set_awake_cb(void (*cb)(void *)</A>, <a href="Fl.html#Fl.thread_message">void *thread_message()</A>, <a href="Fl.html#Fl.unlock">void unlock()</A>. |
