diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2011-01-08 16:31:55 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2011-01-08 16:31:55 +0000 |
| commit | 0b6b69caaa4de4cd3bf5a2e2ebb1a94b1132e823 (patch) | |
| tree | 4846fe3e800834b33783921688014c7b9cd2ee69 /branch-3.0-2011/documentation/src/advanced.dox | |
| parent | 2dc664935d8109767c2d107c6b644082fe06ac05 (diff) | |
Accidentaly copied here
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8219 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'branch-3.0-2011/documentation/src/advanced.dox')
| -rw-r--r-- | branch-3.0-2011/documentation/src/advanced.dox | 129 |
1 files changed, 0 insertions, 129 deletions
diff --git a/branch-3.0-2011/documentation/src/advanced.dox b/branch-3.0-2011/documentation/src/advanced.dox deleted file mode 100644 index 2d8012a1a..000000000 --- a/branch-3.0-2011/documentation/src/advanced.dox +++ /dev/null @@ -1,129 +0,0 @@ -/** - - \page advanced Advanced FLTK - -This chapter explains advanced programming and design topics -that will help you to get the most out of FLTK. - -\section advanced_multithreading Multithreading - -FLTK supports multithreaded applications using a locking mechanism -based on "pthreads". We do not provide a threading interface as part of -the library. However a simple example how threads can be implemented -for all supported platforms can be found in \p test/threads.h -and \p test/threads.cxx. - -To use the locking mechanism, FLTK must be compiled with -\p --enable-threads set during the \p configure -process. IDE-based versions of FLTK are automatically compiled with -locking enabled if possible. - -In \p main(), call -Fl::lock() before -Fl::run() or -Fl::wait() to start the runtime -multithreading support for your program. All callbacks and derived -functions like \p handle() and \p draw() will now be properly -locked: - -\code - int main() { - Fl::lock(); - /* run thread */ - while (Fl::wait() > 0) { - if (Fl::thread_message()) { - /* process your data */ - } - } - } -\endcode - -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(): - -\code - Fl::lock(); // avoid conflicting calls - ... // your code here - Fl::unlock(); // allow other threads to access FLTK again -\endcode - -You can send messages from child threads to the main thread -using Fl::awake(void* message): - -\code - void *msg; // "msg" is a pointer to your message - Fl::awake(msg); // send "msg" to main thread -\endcode - -A message can be anything you like. The main thread can retrieve -the message by calling Fl::thread_message(). See example above. - -You can also tell the main thread to call a function for you -as soon as possible by using -Fl::awake(Fl_Awake_Handler cb, void* userdata): - -\code - void do_something(void *userdata) { - // running with the main thread - } - - // running in another thread - void *data; // "data" is a pointer to your user data - Fl::awake(do_something, data); // call something in main thread -\endcode - - -FLTK supports multiple platforms, some of which allow only the -main thread to handle system events and open or close windows. -The safe thing to do is to adhere to the following rules for -threads on all operating systems: - - -\li Don't \p show() or \p hide() anything that contains - widgets derived from Fl_Window, including dialogs, file - choosers, subwindows or those using Fl_Gl_Window. - -\li Don't call Fl::wait(), Fl::flush() or any - related methods that will handle system messages - -\li Don't start or cancel timers - -\li Don't change window decorations or titles - -\li The \p make_current() method may or may not work well for - regular windows, but should always work for a Fl_Gl_Window - to allow for high speed rendering on graphics cards with multiple - pipelines - -See also: -Fl::awake(void* message), -Fl::lock(), -Fl::thread_message(), -Fl::unlock(). - - -\htmlonly -<hr> -<table summary="navigation bar" width="100%" border="0"> -<tr> - <td width="45%" align="LEFT"> - <a class="el" href="fluid.html"> - [Prev] - Programming with FLUID - </a> - </td> - <td width="10%" align="CENTER"> - <a class="el" href="main.html">[Index]</a> - </td> - <td width="45%" align="RIGHT"> - <a class="el" href="unicode.html"> - Unicode and utf-8 Support - [Next] - </a> - </td> -</tr> -</table> -\endhtmlonly - -*/ |
