diff options
| author | Michael R Sweet <michael.r.sweet@gmail.com> | 2007-01-28 20:03:31 +0000 |
|---|---|---|
| committer | Michael R Sweet <michael.r.sweet@gmail.com> | 2007-01-28 20:03:31 +0000 |
| commit | 2fcd3610d57dacb6d4836991f05ea9728929c10d (patch) | |
| tree | ed2e1809b01be096efc9a2a5a8dffda91bab560c /src/Fl_lock.cxx | |
| parent | ae8675a45fb6418d6a994b3b159be8bedb8689ef (diff) | |
Fl::awake() could block on X11 and OSX (STR #1537)
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@5646 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_lock.cxx')
| -rw-r--r-- | src/Fl_lock.cxx | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/Fl_lock.cxx b/src/Fl_lock.cxx index 895e78021..6f3b44f2c 100644 --- a/src/Fl_lock.cxx +++ b/src/Fl_lock.cxx @@ -127,9 +127,10 @@ void Fl::awake(void* msg) { // POSIX threading... #elif HAVE_PTHREAD # include <unistd.h> +# include <fcntl.h> # include <pthread.h> -# if defined (PTHREAD_MUTEX_RECURSIVE_NP) +# ifdef PTHREAD_MUTEX_RECURSIVE_NP // Linux supports recursive locks, use them directly: static bool minit; @@ -149,7 +150,7 @@ void Fl::unlock() { pthread_mutex_unlock(&fltk_mutex); } -# else +# else // !PTHREAD_MUTEX_RECURSIVE_NP // Make a recursive lock out of the pthread mutex: static pthread_mutex_t fltk_mutex = PTHREAD_MUTEX_INITIALIZER; @@ -168,7 +169,7 @@ void Fl::unlock() { if (!--counter) pthread_mutex_unlock(&fltk_mutex); } -# endif +# endif // PTHREAD_MUTEX_RECURSIVE_NP // Pipe for thread messaging... static int thread_filedes[2]; @@ -193,6 +194,8 @@ void Fl::lock() { if (!thread_filedes[1]) { // initialize the mt support // Init threads communication pipe to let threads awake FLTK from wait pipe(thread_filedes); + fcntl(thread_filedes[1], F_SETFL, + fcntl(thread_filedes[1], F_GETFL) | O_NONBLOCK); Fl::add_fd(thread_filedes[0], FL_READ, thread_awake_cb); fl_lock_function = lock_function; fl_unlock_function = Fl::unlock; @@ -203,7 +206,7 @@ void Fl::awake(void* msg) { write(thread_filedes[1], &msg, sizeof(void*)); } -#endif +#endif // WIN32 // // End of "$Id$". |
