diff options
author | sebres <sebres@users.sourceforge.net> | 2017-04-05 19:52:23 (GMT) |
---|---|---|
committer | sebres <sebres@users.sourceforge.net> | 2017-04-05 19:52:23 (GMT) |
commit | 9bb9d59d856e33313c1f34ec3eb2ac1e0bc145c5 (patch) | |
tree | b7f09e8cc0487921bd391309b69ba533825b0277 | |
parent | 21c607d91ac4d1bd5fbe8820ec592293970c347f (diff) | |
download | tcl-9bb9d59d856e33313c1f34ec3eb2ac1e0bc145c5.zip tcl-9bb9d59d856e33313c1f34ec3eb2ac1e0bc145c5.tar.gz tcl-9bb9d59d856e33313c1f34ec3eb2ac1e0bc145c5.tar.bz2 |
the same handling to initialize thread without suspend/resume helpers (otherwise may be dangerous by very huge resp. too busy system);
-rw-r--r-- | win/tclWinConsole.c | 12 | ||||
-rw-r--r-- | win/tclWinPipe.c | 14 | ||||
-rw-r--r-- | win/tclWinSerial.c | 6 |
3 files changed, 15 insertions, 17 deletions
diff --git a/win/tclWinConsole.c b/win/tclWinConsole.c index 42bc56f..d4893ee 100644 --- a/win/tclWinConsole.c +++ b/win/tclWinConsole.c @@ -1208,8 +1208,7 @@ ConsoleReaderThread( /* * Notify caller (using startEvent) that this thread is initialized */ - SetEvent(threadInfo->startEvent); - SuspendThread(threadInfo->thread); /* until main thread get an event */ + SignalObjectAndWait(threadInfo->startEvent, threadInfo->stopEvent, INFINITE, FALSE); /* * The first event takes precedence. @@ -1321,8 +1320,7 @@ ConsoleWriterThread( /* * Notify caller (using startEvent) that this thread is initialized */ - SetEvent(threadInfo->startEvent); - SuspendThread(threadInfo->thread); /* until main thread get an event */ + SignalObjectAndWait(threadInfo->startEvent, threadInfo->stopEvent, INFINITE, FALSE); /* * The first event takes precedence. @@ -1480,11 +1478,11 @@ TclWinOpenConsoleChannel( */ if (wEventsCnt) { WaitForMultipleObjects(wEventsCnt, wEvents, TRUE, 5000); - /* Resume both waiting threads */ + /* Resume both waiting threads, we've get the events */ if (infoPtr->reader.thread) - ResumeThread(infoPtr->reader.thread); + SetEvent(infoPtr->reader.stopEvent); if (infoPtr->writer.thread) - ResumeThread(infoPtr->writer.thread); + SetEvent(infoPtr->writer.stopEvent); } /* * Files have default translation of AUTO and ^Z eof char, which means diff --git a/win/tclWinPipe.c b/win/tclWinPipe.c index fce039c..523d4eb 100644 --- a/win/tclWinPipe.c +++ b/win/tclWinPipe.c @@ -1638,11 +1638,11 @@ TclpCreateCommandChannel( */ if (wEventsCnt) { WaitForMultipleObjects(wEventsCnt, wEvents, TRUE, 5000); - /* Resume both waiting threads */ + /* Resume both waiting threads, we've get the events */ if (infoPtr->readThread) - ResumeThread(infoPtr->readThread); + SetEvent(infoPtr->stopReader); if (infoPtr->writeThread) - ResumeThread(infoPtr->writeThread); + SetEvent(infoPtr->stopWriter); } /* @@ -2879,8 +2879,8 @@ PipeReaderThread( /* * Notify caller that this thread has been initialized */ - SetEvent(infoPtr->startReader); - SuspendThread(infoPtr->readThread); /* until main thread get an event */ + SignalObjectAndWait(infoPtr->startReader, infoPtr->stopReader, INFINITE, FALSE); + ResetEvent(infoPtr->stopReader); /* not auto-reset */ wEvents[0] = infoPtr->stopReader; wEvents[1] = infoPtr->startReader; @@ -3015,8 +3015,8 @@ PipeWriterThread( /* * Notify caller that this thread has been initialized */ - SetEvent(infoPtr->startWriter); - SuspendThread(infoPtr->writeThread); /* until main thread get an event */ + SignalObjectAndWait(infoPtr->startWriter, infoPtr->stopWriter, INFINITE, FALSE); + ResetEvent(infoPtr->stopWriter); /* not auto-reset */ wEvents[0] = infoPtr->stopWriter; wEvents[1] = infoPtr->startWriter; diff --git a/win/tclWinSerial.c b/win/tclWinSerial.c index fa135ab..f55f5f1 100644 --- a/win/tclWinSerial.c +++ b/win/tclWinSerial.c @@ -1339,8 +1339,7 @@ SerialWriterThread( /* * Notify TclWinOpenSerialChannel() that this thread is initialized */ - SetEvent(infoPtr->evStartWriter); - SuspendThread(infoPtr->writeThread); /* until main thread get an event */ + SignalObjectAndWait(infoPtr->evStartWriter, infoPtr->evStopWriter, INFINITE, FALSE); /* * The stop event takes precedence by being first in the list. @@ -1565,7 +1564,8 @@ TclWinOpenSerialChannel( infoPtr, 0, &id); /* Wait for thread to initialize (using evStartWriter) */ WaitForSingleObject(infoPtr->evStartWriter, 5000); - ResumeThread(infoPtr->writeThread); + /* Wake-up it to signal we've get an event */ + SetEvent(infoPtr->evStopWriter); } /* |