From 501690edce2cecc356334fc42e7f429907cdfa1e Mon Sep 17 00:00:00 2001
From: Fabien Costantini
Date: Fri, 17 Oct 2008 11:08:15 +0000
Subject: Last test does keep history, lets add all related files and patch
them afterwards...
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6447 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
---
documentation/src_doc/advanced.dox | 113 +++++++++++++++++++++++++++++++++++++
1 file changed, 113 insertions(+)
create mode 100644 documentation/src_doc/advanced.dox
(limited to 'documentation/src_doc/advanced.dox')
diff --git a/documentation/src_doc/advanced.dox b/documentation/src_doc/advanced.dox
new file mode 100644
index 000000000..17afa9147
--- /dev/null
+++ b/documentation/src_doc/advanced.dox
@@ -0,0 +1,113 @@
+/**
+
+ \page advanced 10 - 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 application 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 test/threads.h
+and test/threads.cxx.
+
+To use the locking mechanism, FLTK must be compiled with
+--enable-threads set during the configure
+process. IDE-based versions of FLTK are automatically compiled with
+locking enabled if possible.
+
+In 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 handle() and 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(msg):
+
+\code
+ void *msg; // "msg" is a pointer to your message
+ Fl::awake(msg); // send "msg" to main thread
+\endcode
+
+You can also tell the main thread to call a function for you
+as soon as possible by using
+Fl::awake(callback, 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 them which do not
+allow any other but 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 show() or hide()anything that contains
+ widgets derived from Fl_Window, including dialogs, file
+ choosers, subwindows or Fl_GL_Windows
+
+\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 make_current() method may or may not work well for
+ regular windows, but should always work for Fl_GL_Windows
+ to allow for high speed rendering on graphics cards with multiple
+ pipelines
+
+See also:
+void awake(void *message),
+void lock(),
+void *thread_message(),
+void unlock().
+
+\htmlonly
+
+[Index]
+[Previous] 9 - Programming with FLUID
+[Next] 11 - Unicode and utf-8 Support
+\endhtmlonly
+*/
--
cgit v1.2.3