From 6e9a1630357a21c6ef6357cdde324ae89a565826 Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Thu, 8 Feb 2007 23:04:20 +0000 Subject: Add handler for thread messages (STR #1536) git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@5683 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- documentation/advanced.html | 38 ++++++++++++-------------------------- 1 file changed, 12 insertions(+), 26 deletions(-) (limited to 'documentation/advanced.html') diff --git a/documentation/advanced.html b/documentation/advanced.html index 52c3009b6..51ea1895b 100644 --- a/documentation/advanced.html +++ b/documentation/advanced.html @@ -9,24 +9,13 @@

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

-

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

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, the command line version of 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. +

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(), before calling Fl::run(), call -Fl::lock(). This will startup the runtime multithreading -support for your program. All callbacks and derived functions -like handle() and draw() will now be properly -locked. +

In main(), call Fl::lock() before Fl::run() to start the runtime multithreading support for your program. All callbacks and derived functions like handle() and draw() will now be properly locked.

   main() {
@@ -56,34 +45,31 @@ in the following code:
 

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 rulesi for threads on all operating systems. +following rules for threads on all operating systems:

    -
  • don't show() or hide()anything that contains +
  • Don't show() or hide()anything that contains widgets derived from Fl_Window, including dialogs, file choosers, subwindows or Fl_GL_Windows
  • -
  • don't call Fl::wait(), Fl::flush() or any +
  • Don't call Fl::wait(), Fl::flush() or any related methods that will handle system messages
  • -
  • don't start or cancel timers
  • +
  • Don't start or cancel timers
  • -
  • don't change window decorations or titles
  • +
  • Don't change window decorations or titles
  • -
  • make_current() 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
  • +
  • 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 unlock(), -void awake(void *message), +void set_awake_cb(void (*cb)(void *), void *thread_message(). - -- cgit v1.2.3