1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
-
+
|
/*
* tclWinThread.c --
*
* This file implements the Windows-specific thread operations.
*
* Copyright (c) 1998 by Sun Microsystems, Inc.
* Copyright (c) 1999 by Scriptics Corporation
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
* RCS: @(#) $Id: tclWinThrd.c,v 1.24.2.11 2005/05/30 01:36:53 hobbs Exp $
* RCS: @(#) $Id: tclWinThrd.c,v 1.24.2.12 2007/03/24 09:31:11 vasiljevic Exp $
*/
#include "tclWinInt.h"
#include <fcntl.h>
#include <io.h>
#include <sys/stat.h>
|
| ︙ | | |
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
-
-
|
/*
* State bits for the thread.
* WIN_THREAD_UNINIT Uninitialized. Must be zero because
* of the way ThreadSpecificData is created.
* WIN_THREAD_RUNNING Running, not waiting.
* WIN_THREAD_BLOCKED Waiting, or trying to wait.
* WIN_THREAD_DEAD Dying - no per-thread event anymore.
*/
#define WIN_THREAD_UNINIT 0x0
#define WIN_THREAD_RUNNING 0x1
#define WIN_THREAD_BLOCKED 0x2
#define WIN_THREAD_DEAD 0x4
/*
* The per condition queue pointers and the
* Mutex used to serialize access to the queue.
*/
typedef struct WinCondition {
|
| ︙ | | |
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
|
783
784
785
786
787
788
789
790
791
792
793
794
795
796
|
-
-
-
-
-
-
-
-
|
WinCondition *winCondPtr; /* Per-condition queue head */
CRITICAL_SECTION *csPtr; /* Caller's Mutex, after casting */
DWORD wtime; /* Windows time value */
int timeout; /* True if we got a timeout */
int doExit = 0; /* True if we need to do exit setup */
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
if (tsdPtr->flags & WIN_THREAD_DEAD) {
/*
* No more per-thread event on which to wait.
*/
return;
}
/*
* Self initialize the two parts of the condition.
* The per-condition and per-thread parts need to be
* handled independently.
*/
if (tsdPtr->flags == WIN_THREAD_UNINIT) {
|
| ︙ | | |
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
|
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
|
+
+
+
+
+
|
void
Tcl_ConditionNotify(condPtr)
Tcl_Condition *condPtr;
{
WinCondition *winCondPtr;
ThreadSpecificData *tsdPtr;
if (condPtr != NULL) {
winCondPtr = *((WinCondition **)condPtr);
if (winCondPtr == NULL) {
return;
}
/*
* Loop through all the threads waiting on the condition
* and notify them (i.e., broadcast semantics). The queue
* manipulation is guarded by the per-condition coordinating mutex.
*/
|
| ︙ | | |
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
|
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
|
-
+
|
*/
static void
FinalizeConditionEvent(data)
ClientData data;
{
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)data;
tsdPtr->flags = WIN_THREAD_DEAD;
tsdPtr->flags = WIN_THREAD_UNINIT;
CloseHandle(tsdPtr->condEvent);
}
/*
*----------------------------------------------------------------------
*
* TclpFinalizeCondition --
|
| ︙ | | |