summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FL/Fl.H2
-rw-r--r--src/Fl_lock.cxx45
2 files changed, 31 insertions, 16 deletions
diff --git a/FL/Fl.H b/FL/Fl.H
index 4824cb0de..8194ee655 100644
--- a/FL/Fl.H
+++ b/FL/Fl.H
@@ -979,7 +979,7 @@ public:
@{ */
// Multithreading support:
- static void lock();
+ static int lock();
static void unlock();
static void awake(void* message = 0);
/** See void awake(void* message=0). */
diff --git a/src/Fl_lock.cxx b/src/Fl_lock.cxx
index c5c0cd94a..4328be8c3 100644
--- a/src/Fl_lock.cxx
+++ b/src/Fl_lock.cxx
@@ -121,11 +121,15 @@ int Fl::get_awake_handler_(Fl_Awake_Handler &func, void *&data)
return ret;
}
-//
/**
- Let the main thread know an update is pending
- and have it call a specific function
- See void awake(void* message=0).
+ Let the main thread know an update is pending and have it call a specific function.
+ Registers a function that will be
+ called by the main thread during the next message handling cycle.
+ Returns 0 if the callback function was registered,
+ and -1 if registration failed. Over a thousand awake callbacks can be
+ registered simultaneously.
+
+ \see Fl::awake(void* message=0)
*/
int Fl::awake(Fl_Awake_Handler func, void *data) {
int ret = add_awake_handler_(func, data);
@@ -135,12 +139,13 @@ int Fl::awake(Fl_Awake_Handler func, void *data) {
////////////////////////////////////////////////////////////////
// Windows threading...
-/** \fn void Fl::lock()
+/** \fn int Fl::lock()
The lock() method blocks the current thread until it
can safely access FLTK widgets and data. Child threads should
call this method prior to updating any widgets or accessing
data. The main thread must call lock() to initialize
- the threading support in FLTK.
+ the threading support in FLTK. lock() will return non-zero
+ if threading is not available on the platform.
Child threads must call unlock() when they are done
accessing FLTK.
@@ -150,6 +155,9 @@ int Fl::awake(Fl_Awake_Handler func, void *data) {
Similarly, when the main thread needs to do processing, it will
wait until all child threads have called unlock() before processing
additional data.
+
+ \return 0 if threading is available on the platform; non-zero
+ otherwise.
See also: \ref advanced_multithreading
*/
@@ -162,7 +170,7 @@ int Fl::awake(Fl_Awake_Handler func, void *data) {
See also: \ref advanced_multithreading
*/
/** \fn void Fl::awake(void* msg)
- The awake() method sends a message pointer to the main thread,
+ Sends a message pointer to the main thread,
causing any pending Fl::wait() call to
terminate so that the main thread can retrieve the message and any pending
redraws can be processed.
@@ -172,12 +180,6 @@ int Fl::awake(Fl_Awake_Handler func, void *data) {
thousand) depth. The default message handler saves the last message which
can be accessed using the
Fl::thread_message() function.
-
- The second form of awake() registers a function that will be
- called by the main thread during the next message handling cycle.
- awake() will return 0 if the callback function was registered,
- and -1 if registration failed. Over a thousand awake callbacks can be
- registered simultaneously.
In the context of a threaded application, a call to Fl::awake() with no
argument will trigger event loop handling in the main thread. Since
@@ -230,7 +232,7 @@ static void lock_function() {
EnterCriticalSection(&cs);
}
-void Fl::lock() {
+int Fl::lock() {
if (!main_thread) InitializeCriticalSection(&cs);
lock_function();
@@ -240,6 +242,7 @@ void Fl::lock() {
fl_unlock_function = unlock_function;
main_thread = GetCurrentThreadId();
}
+ return 0;
}
void Fl::unlock() {
@@ -329,7 +332,7 @@ static void thread_awake_cb(int fd, void*) {
extern void (*fl_lock_function)();
extern void (*fl_unlock_function)();
-void Fl::lock() {
+int Fl::lock() {
if (!thread_filedes[1]) {
// Initialize thread communication pipe to let threads awake FLTK
// from Fl::wait()
@@ -364,6 +367,7 @@ void Fl::lock() {
}
fl_lock_function();
+ return 0;
}
void Fl::unlock() {
@@ -396,6 +400,17 @@ void lock_ring() {
void Fl::awake(void*) {
}
+int Fl::lock() {
+ return 1;
+}
+
+void Fl::unlock() {
+}
+
+void* Fl::thread_message() {
+ return NULL;
+}
+
#endif // WIN32
//