summaryrefslogtreecommitdiff
path: root/src/Fl_win32.cxx
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>2001-12-06 22:16:49 +0000
committerMichael R Sweet <michael.r.sweet@gmail.com>2001-12-06 22:16:49 +0000
commitba2be02ab24d170bb03662a8a5f5893f0112aeb7 (patch)
tree7474e6b1a3da5d4c8aaf3c73c4b2e43f607c444a /src/Fl_win32.cxx
parent7710dc14a88f02bad07111cc2e29414f2513b28d (diff)
FLTK 2.0 threading support under FLTK 1.1. Needs porting to OSX.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1819 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_win32.cxx')
-rw-r--r--src/Fl_win32.cxx29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/Fl_win32.cxx b/src/Fl_win32.cxx
index de80c9d0a..c54687a60 100644
--- a/src/Fl_win32.cxx
+++ b/src/Fl_win32.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_win32.cxx,v 1.33.2.37.2.9 2001/11/30 16:10:08 easysw Exp $"
+// "$Id: Fl_win32.cxx,v 1.33.2.37.2.10 2001/12/06 22:16:49 easysw Exp $"
//
// WIN32-specific code for the Fast Light Tool Kit (FLTK).
//
@@ -164,6 +164,18 @@ void Fl::remove_fd(int n) {
remove_fd(n, -1);
}
+// these pointers are set by the Fl::lock() function:
+static void nothing() {}
+void (*fl_lock_function)() = nothing;
+void (*fl_unlock_function)() = nothing;
+
+static void* thread_message_;
+void* Fl::thread_message() {
+ void* r = thread_message_;
+ thread_message_ = 0;
+ return r;
+}
+
MSG fl_msg;
// This is never called with time_to_wait < 0.0.
@@ -206,12 +218,17 @@ int fl_wait(double time_to_wait) {
}
#endif // USE_ASYNC_SELECT
+ fl_unlock_function();
+
if (time_to_wait < 2147483.648) {
// Perform the requested timeout...
have_message = PeekMessage(&fl_msg, NULL, 0, 0, PM_REMOVE);
if (!have_message) {
int t = (int)(time_to_wait * 1000.0 + .5);
- if (t <= 0) return 0; // too short to measure
+ if (t <= 0) { // too short to measure
+ fl_lock_function();
+ return 0;
+ }
timerid = SetTimer(NULL, 0, t, NULL);
have_message = GetMessage(&fl_msg, NULL, 0, 0);
KillTimer(NULL, timerid);
@@ -220,6 +237,8 @@ int fl_wait(double time_to_wait) {
have_message = GetMessage(&fl_msg, NULL, 0, 0);
}
+ fl_lock_function();
+
// Execute the message we got, and all other pending messages:
while (have_message) {
#ifdef USE_ASYNC_SELECT
@@ -233,6 +252,10 @@ int fl_wait(double time_to_wait) {
// looks like it is best to do the dispatch-message anyway:
}
#endif
+
+ if (fl_msg.message == WM_USER) // Used for awaking wait() from another thread
+ thread_message_ = (void*)fl_msg.wParam;
+
TranslateMessage(&fl_msg);
DispatchMessage(&fl_msg);
have_message = PeekMessage(&fl_msg, NULL, 0, 0, PM_REMOVE);
@@ -997,5 +1020,5 @@ void Fl_Window::make_current() {
}
//
-// End of "$Id: Fl_win32.cxx,v 1.33.2.37.2.9 2001/11/30 16:10:08 easysw Exp $".
+// End of "$Id: Fl_win32.cxx,v 1.33.2.37.2.10 2001/12/06 22:16:49 easysw Exp $".
//