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)
commita02181c703599ee79a70f4463262b1cfd6598349 (patch)
tree1b855b6b0ffa0d3e208cf79e38d1b38d47dab3c2 /unix/tclUnixNotfy.c
parentd8427a64ce8b8693bba75617d6c9495fe2210a3c (diff)
parente06ad27aa954e1d75f2ec38a9d6289e82b1ce974 (diff)
downloadtcl-a02181c703599ee79a70f4463262b1cfd6598349.zip
tcl-a02181c703599ee79a70f4463262b1cfd6598349.tar.gz
tcl-a02181c703599ee79a70f4463262b1cfd6598349.tar.bz2
first working version of Cygwin notifier
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);