summaryrefslogtreecommitdiffstats
path: root/unix/tclUnixNotfy.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2012-06-22 08:29:53 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2012-06-22 08:29:53 (GMT)
commit5680fa44dbfafeed01f328dd8cde4310c3c95ba6 (patch)
tree1b855b6b0ffa0d3e208cf79e38d1b38d47dab3c2 /unix/tclUnixNotfy.c
parent4731d0ccca76a01ad1401b71b70c9e6f1e372050 (diff)
parentb6f50b1321a5cd34af747eb670aad924fc66d7b7 (diff)
downloadtcl-5680fa44dbfafeed01f328dd8cde4310c3c95ba6.zip
tcl-5680fa44dbfafeed01f328dd8cde4310c3c95ba6.tar.gz
tcl-5680fa44dbfafeed01f328dd8cde4310c3c95ba6.tar.bz2
first working version of Cygwin notifierbug_3508771
Diffstat (limited to 'unix/tclUnixNotfy.c')
-rw-r--r--unix/tclUnixNotfy.c34
1 files changed, 28 insertions, 6 deletions
diff --git a/unix/tclUnixNotfy.c b/unix/tclUnixNotfy.c
index aff51b1..ab1f160 100644
--- a/unix/tclUnixNotfy.c
+++ b/unix/tclUnixNotfy.c
@@ -103,10 +103,11 @@ typedef struct ThreadSpecificData {
* that an event is ready to be processed
* by sending this event. */
void *hwnd; /* Messaging window. */
-#endif /* __CYGWIN__ */
+#else /* !__CYGWIN__ */
Tcl_Condition waitCV; /* Any other thread alerts a notifier
* that an event is ready to be processed
* by signaling this condition variable. */
+#endif /* __CYGWIN__ */
int eventReady; /* True if an event is ready to be processed.
* Used as condition flag together with
* waitCV above. */
@@ -354,8 +355,9 @@ Tcl_FinalizeNotifier(clientData)
#ifdef __CYGWIN__
CloseHandle(tsdPtr->event);
-#endif /* __CYGWIN__ */
+#else /* __CYGWIN__ */
Tcl_ConditionFinalize(&(tsdPtr->waitCV));
+#endif /* __CYGWIN__ */
Tcl_MutexUnlock(&notifierMutex);
#endif
@@ -390,7 +392,11 @@ Tcl_AlertNotifier(clientData)
ThreadSpecificData *tsdPtr = (ThreadSpecificData *) clientData;
Tcl_MutexLock(&notifierMutex);
tsdPtr->eventReady = 1;
+#ifdef __CYGWIN__
+ PostMessageW(tsdPtr->hwnd, 1024, 0, 0);
+#else
Tcl_ConditionNotify(&tsdPtr->waitCV);
+#endif
Tcl_MutexUnlock(&notifierMutex);
#endif
}
@@ -832,9 +838,7 @@ Tcl_WaitForEvent(timePtr)
class.hIcon = NULL;
class.hCursor = NULL;
- if (!RegisterClassW(&class)) {
- Tcl_Panic("Unable to register TclNotifier window class");
- }
+ RegisterClassW(&class);
tsdPtr->hwnd = CreateWindowExW(NULL, class.lpszClassName, class.lpszClassName,
0, 0, 0, 0, 0, NULL, NULL, TclWinGetTclInstance(), NULL);
tsdPtr->event = CreateEventW(NULL, 1 /* manual */,
@@ -866,7 +870,21 @@ Tcl_WaitForEvent(timePtr)
FD_ZERO( &(tsdPtr->readyMasks.exceptional) );
if (!tsdPtr->eventReady) {
- Tcl_ConditionWait(&tsdPtr->waitCV, &notifierMutex, timePtr);
+#ifdef __CYGWIN__
+ if (!PeekMessageW(&msg, NULL, 0, 0, 0)) {
+ DWORD timeout;
+ if (timePtr) {
+ timeout = timePtr->sec * 1000 + timePtr->usec / 1000;
+ } else {
+ timeout = 0xFFFFFFFF;
+ }
+ Tcl_MutexUnlock(&notifierMutex);
+ MsgWaitForMultipleObjects(1, &tsdPtr->event, 0, timeout, 1279);
+ Tcl_MutexLock(&notifierMutex);
+ }
+#else
+ Tcl_ConditionWait(&tsdPtr->waitCV, &notifierMutex, timePtr);
+#endif
}
tsdPtr->eventReady = 0;
@@ -1159,7 +1177,11 @@ NotifierThreadProc(clientData)
tsdPtr->onList = 0;
tsdPtr->pollState = 0;
}
+#ifdef __CYGWIN__
+ PostMessageW(tsdPtr->hwnd, 1024, 0, 0);
+#else /* __CYGWIN__ */
Tcl_ConditionNotify(&tsdPtr->waitCV);
+#endif /* __CYGWIN__ */
}
}
Tcl_MutexUnlock(&notifierMutex);