From a6163888f3c56123b1db313743c6147ba498732c Mon Sep 17 00:00:00 2001 From: Yuval Adam Date: Fri, 8 Aug 2014 14:42:07 +0300 Subject: Add third_party libs --- .../fltk-1.1.10/documentation/advanced.html | 95 ++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 third_party/windows/fltk-1.1.10/documentation/advanced.html (limited to 'third_party/windows/fltk-1.1.10/documentation/advanced.html') diff --git a/third_party/windows/fltk-1.1.10/documentation/advanced.html b/third_party/windows/fltk-1.1.10/documentation/advanced.html new file mode 100644 index 0000000..8486095 --- /dev/null +++ b/third_party/windows/fltk-1.1.10/documentation/advanced.html @@ -0,0 +1,95 @@ + + + 10 - Advanced FLTK + + + +

10 - Advanced FLTK

+ +

This chapter explains advanced programming and design topics +that will help you to get the most out of FLTK.

+ +

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:

+ +
+    int main() {
+      Fl::lock();
+      /* run thread */
+      while (Fl::wait() > 0) {
+        if (Fl::thread_message()) {
+          /* process your data */
+        }
+      }
+    }
+
+ +

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(): + +

+    Fl::lock();      // avoid conflicting calls
+    ...              // your code here
+    Fl::unlock();    // allow other threads to access FLTK again
+
+ +

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
+
+ +

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

+ +
+    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
+
+ + +

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: + +

+ +

See also: +void awake(void *message), +void lock(), +void *thread_message(), +void unlock(). + + + -- cgit v1.3.1