Diff
Not logged in

Differences From Artifact [7ca07022cf]:

To Artifact [34abfae86e]:


106
107
108
109
110
111
112

113
114
115
116
117
118
119
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120







+







	 * that an event is ready to be processed
	 * by sending this event. */
    void *hwnd;			/* Messaging window. */
#else /* !__CYGWIN__ */
    pthread_cond_t waitCV;	/* Any other thread alerts a notifier that an
				 * event is ready to be processed by signaling
				 * this condition variable. */
    int waitCVMono;		/* Mark wait monotonic based */
#endif /* __CYGWIN__ */
    int waitCVinitialized;	/* Variable to flag initialization of the structure */
    int eventReady;		/* > 0 if an event is ready to be processed.
				 * Used as condition flag together with waitCV
				 * above. */
#endif /* TCL_THREADS */
} ThreadSpecificData;
328
329
330
331
332
333
334

335
336
337
338
339
340
341
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343







+







 *----------------------------------------------------------------------
 */

ClientData
Tcl_InitNotifier(void)
{
    ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
    pthread_condattr_t wcvAttr, *wcvAttrPtr = NULL;

#ifdef TCL_THREADS
    tsdPtr->eventReady = 0;

    /*
     * Initialize thread specific condition variable for this thread.
     */
357
358
359
360
361
362
363






364


365
366
367
368
369
370
371
359
360
361
362
363
364
365
366
367
368
369
370
371

372
373
374
375
376
377
378
379
380







+
+
+
+
+
+
-
+
+







	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 */,
		0 /* !signaled */, NULL);
#else
	pthread_condattr_init(&wcvAttr);
        if (pthread_condattr_setclock(&wcvAttr, CLOCK_MONOTONIC) == 0) {
	    /* we can use conditional wait monotonic based */
	    wcvAttrPtr = &wcvAttr;
	    tsdPtr->waitCVMono = 1;
        }
	pthread_cond_init(&tsdPtr->waitCV, NULL);
	pthread_cond_init(&tsdPtr->waitCV, wcvAttrPtr);
        (void)pthread_condattr_destroy(&wcvAttr);
#endif /* __CYGWIN__ */
	tsdPtr->waitCVinitialized = 1;
    }

    pthread_mutex_lock(&notifierInitMutex);
#if defined(HAVE_PTHREAD_ATFORK)
    /*
1112
1113
1114
1115
1116
1117
1118

1119

1120
1121
1122
1123
1124
1125
1126
1121
1122
1123
1124
1125
1126
1127
1128

1129
1130
1131
1132
1133
1134
1135
1136







+
-
+







	else
	if (timePtr) {
	    struct timespec ptime;

	    /* TIP #233: Scale from virtual time to real-time  */
	    TclpScaleUTime(&waitTime);

	    clock_gettime(tsdPtr->waitCVMono ? 
	    clock_gettime(CLOCK_REALTIME, &ptime);
		CLOCK_MONOTONIC : CLOCK_REALTIME, &ptime);
	    ptime.tv_sec += waitTime / 1000000;
	    ptime.tv_nsec += (waitTime % 1000000) * 1000;
	    if (ptime.tv_nsec > 1000000*1000) {
		ptime.tv_nsec -= 1000000*1000;
		ptime.tv_sec++;
	    }

1147
1148
1149
1150
1151
1152
1153
1154

1155
1156
1157
1158
1159
1160
1161
1157
1158
1159
1160
1161
1162
1163

1164
1165
1166
1167
1168
1169
1170
1171







-
+







#endif /* __APPLE__ && __LP64__ */

	    if (ptime.tv_nsec > 1000000*1000) {
		ptime.tv_nsec -= 1000000*1000;
		ptime.tv_sec++;
	    }
	    if (pthread_cond_timedwait(&tsdPtr->waitCV, &notifierMutex,
	    		&ptime) == ETIMEDOUT) {
			&ptime) == ETIMEDOUT) {
		continue; /* repeat wait (if not yet real timeout) */
	    };
	} else {
	    pthread_cond_wait(&tsdPtr->waitCV, &notifierMutex);
	}
#endif /* __CYGWIN__ */