diff options
author | davygrvy <davygrvy@noemail.net> | 2004-03-03 10:44:41 (GMT) |
---|---|---|
committer | davygrvy <davygrvy@noemail.net> | 2004-03-03 10:44:41 (GMT) |
commit | 89f3326bb6e143c1d1ea14acf313973ef17e97db (patch) | |
tree | cb2e0c736b2641c662e63fca820f81c3901ad0de /win/tclWinNotify.c | |
parent | 43781332e801eaa31912c0f637b113fb53aae07f (diff) | |
download | tcl-89f3326bb6e143c1d1ea14acf313973ef17e97db.zip tcl-89f3326bb6e143c1d1ea14acf313973ef17e97db.tar.gz tcl-89f3326bb6e143c1d1ea14acf313973ef17e97db.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.
FossilOrigin-Name: cc0704a50f1da6ecac58b4056b59a578591e4029
Diffstat (limited to 'win/tclWinNotify.c')
-rw-r--r-- | win/tclWinNotify.c | 20 |
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; } |