summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authordavygrvy <davygrvy@pobox.com>2004-03-03 10:44:41 (GMT)
committerdavygrvy <davygrvy@pobox.com>2004-03-03 10:44:41 (GMT)
commit7fc02cf80b3b22f9765e15415e1aa0a175a3aca8 (patch)
treecb2e0c736b2641c662e63fca820f81c3901ad0de /win
parent041b24a33a73da42cb02cf8149a56985fef56350 (diff)
downloadtcl-7fc02cf80b3b22f9765e15415e1aa0a175a3aca8.zip
tcl-7fc02cf80b3b22f9765e15415e1aa0a175a3aca8.tar.gz
tcl-7fc02cf80b3b22f9765e15415e1aa0a175a3aca8.tar.bz2
* win/tclWinNotify.c (Tcl_WaitForEvent) : Allows an idling notifier to service
"Asynchronous Procedure Calls" from its wait state. Only useful for extension authors who decide they might want to try "completion routines" with WriteFileEx(), as an example. From experience, I recommend that "completion ports" should be used instead as the execution of the callbacks are more managable.
Diffstat (limited to 'win')
-rw-r--r--win/tclWinNotify.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/win/tclWinNotify.c b/win/tclWinNotify.c
index 65faf8e..02e8d64 100644
--- a/win/tclWinNotify.c
+++ b/win/tclWinNotify.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclWinNotify.c,v 1.13 2003/12/24 04:18:22 davygrvy Exp $
+ * RCS: @(#) $Id: tclWinNotify.c,v 1.14 2004/03/03 10:44:41 davygrvy Exp $
*/
#include "tclWinInt.h"
@@ -458,18 +458,27 @@ Tcl_WaitForEvent(
if (!PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) {
/*
* Wait for something to happen (a signal from another thread, a
- * message, or timeout).
+ * message, or timeout) or loop servicing asynchronous procedure
+ * calls queued to this thread.
*/
- result = MsgWaitForMultipleObjects(1, &tsdPtr->event, FALSE, timeout,
- QS_ALLINPUT);
+again:
+ result = MsgWaitForMultipleObjectsEx(1, &tsdPtr->event, timeout,
+ QS_ALLINPUT, MWMO_ALERTABLE);
+ if (result == WAIT_IO_COMPLETION) {
+ goto again;
+ } else if (result == WAIT_FAILED) {
+ status = -1;
+ goto end;
+ }
}
/*
* Check to see if there are any messages to process.
*/
- if (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) {
+ if (result == (WAIT_OBJECT_0 + 1) ||
+ PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) {
/*
* Retrieve and dispatch the first message.
*/
@@ -499,6 +508,7 @@ Tcl_WaitForEvent(
status = 0;
}
+end:
ResetEvent(tsdPtr->event);
return status;
}