summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2022-07-03 22:32:18 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2022-07-03 22:32:18 (GMT)
commit2a491f190de48515f16da9159bdeaf78278470d8 (patch)
tree563d97e84302ea4d48053e330e0af63a423ce21c /generic
parent2ae930bbe476ece1b6b363a888b2e47388620f92 (diff)
parent2eb04855330919d1164b6f03a187b601478fad27 (diff)
downloadtcl-2a491f190de48515f16da9159bdeaf78278470d8.zip
tcl-2a491f190de48515f16da9159bdeaf78278470d8.tar.gz
tcl-2a491f190de48515f16da9159bdeaf78278470d8.tar.bz2
Merge 8.7
Diffstat (limited to 'generic')
-rw-r--r--generic/tcl.decls4
-rw-r--r--generic/tcl.h5
-rw-r--r--generic/tclDecls.h9
-rw-r--r--generic/tclIORChan.c8
-rw-r--r--generic/tclIORTrans.c4
-rw-r--r--generic/tclNotify.c40
-rw-r--r--generic/tclTest.c2
-rw-r--r--generic/tclThreadTest.c3
8 files changed, 42 insertions, 33 deletions
diff --git a/generic/tcl.decls b/generic/tcl.decls
index 1312434..0c770c0 100644
--- a/generic/tcl.decls
+++ b/generic/tcl.decls
@@ -756,7 +756,7 @@ declare 204 {
const char *Tcl_PosixError(Tcl_Interp *interp)
}
declare 205 {
- void Tcl_QueueEvent(Tcl_Event *evPtr, Tcl_QueuePosition position)
+ void Tcl_QueueEvent(Tcl_Event *evPtr, int flags)
}
declare 206 {
size_t Tcl_Read(Tcl_Channel chan, char *bufPtr, size_t toRead)
@@ -1189,7 +1189,7 @@ declare 318 {
}
declare 319 {
void Tcl_ThreadQueueEvent(Tcl_ThreadId threadId, Tcl_Event *evPtr,
- Tcl_QueuePosition position)
+ int flags)
}
declare 320 {
int Tcl_UniCharAtIndex(const char *src, size_t index)
diff --git a/generic/tcl.h b/generic/tcl.h
index 0e66d0c..b9061c7 100644
--- a/generic/tcl.h
+++ b/generic/tcl.h
@@ -1168,11 +1168,12 @@ struct Tcl_Event {
};
/*
- * Positions to pass to Tcl_QueueEvent:
+ * Positions to pass to Tcl_QueueEvent/Tcl_ThreadQueueEvent:
*/
typedef enum {
- TCL_QUEUE_TAIL, TCL_QUEUE_HEAD, TCL_QUEUE_MARK
+ TCL_QUEUE_TAIL, TCL_QUEUE_HEAD, TCL_QUEUE_MARK,
+ TCL_QUEUE_ALERT_IF_EMPTY=4
} Tcl_QueuePosition;
/*
diff --git a/generic/tclDecls.h b/generic/tclDecls.h
index 89326af..ff6b0c6 100644
--- a/generic/tclDecls.h
+++ b/generic/tclDecls.h
@@ -571,8 +571,7 @@ EXTERN int Tcl_PutEnv(const char *assignment);
/* 204 */
EXTERN const char * Tcl_PosixError(Tcl_Interp *interp);
/* 205 */
-EXTERN void Tcl_QueueEvent(Tcl_Event *evPtr,
- Tcl_QueuePosition position);
+EXTERN void Tcl_QueueEvent(Tcl_Event *evPtr, int flags);
/* 206 */
EXTERN size_t Tcl_Read(Tcl_Channel chan, char *bufPtr,
size_t toRead);
@@ -848,7 +847,7 @@ EXTERN Tcl_Obj * Tcl_SetVar2Ex(Tcl_Interp *interp, const char *part1,
EXTERN void Tcl_ThreadAlert(Tcl_ThreadId threadId);
/* 319 */
EXTERN void Tcl_ThreadQueueEvent(Tcl_ThreadId threadId,
- Tcl_Event *evPtr, Tcl_QueuePosition position);
+ Tcl_Event *evPtr, int flags);
/* 320 */
EXTERN int Tcl_UniCharAtIndex(const char *src, size_t index);
/* 321 */
@@ -2024,7 +2023,7 @@ typedef struct TclStubs {
void (*tcl_PrintDouble) (Tcl_Interp *interp, double value, char *dst); /* 202 */
int (*tcl_PutEnv) (const char *assignment); /* 203 */
const char * (*tcl_PosixError) (Tcl_Interp *interp); /* 204 */
- void (*tcl_QueueEvent) (Tcl_Event *evPtr, Tcl_QueuePosition position); /* 205 */
+ void (*tcl_QueueEvent) (Tcl_Event *evPtr, int flags); /* 205 */
size_t (*tcl_Read) (Tcl_Channel chan, char *bufPtr, size_t toRead); /* 206 */
void (*tcl_ReapDetachedProcs) (void); /* 207 */
int (*tcl_RecordAndEval) (Tcl_Interp *interp, const char *cmd, int flags); /* 208 */
@@ -2138,7 +2137,7 @@ typedef struct TclStubs {
int (*tcl_SetSystemEncoding) (Tcl_Interp *interp, const char *name); /* 316 */
Tcl_Obj * (*tcl_SetVar2Ex) (Tcl_Interp *interp, const char *part1, const char *part2, Tcl_Obj *newValuePtr, int flags); /* 317 */
void (*tcl_ThreadAlert) (Tcl_ThreadId threadId); /* 318 */
- void (*tcl_ThreadQueueEvent) (Tcl_ThreadId threadId, Tcl_Event *evPtr, Tcl_QueuePosition position); /* 319 */
+ void (*tcl_ThreadQueueEvent) (Tcl_ThreadId threadId, Tcl_Event *evPtr, int flags); /* 319 */
int (*tcl_UniCharAtIndex) (const char *src, size_t index); /* 320 */
int (*tcl_UniCharToLower) (int ch); /* 321 */
int (*tcl_UniCharToTitle) (int ch); /* 322 */
diff --git a/generic/tclIORChan.c b/generic/tclIORChan.c
index 7dc7dd7..67abca6 100644
--- a/generic/tclIORChan.c
+++ b/generic/tclIORChan.c
@@ -984,8 +984,8 @@ TclChanPostEventObjCmd(
* XXX Actually, in that case the channel should be dead also !
*/
- Tcl_ThreadQueueEvent(rcPtr->owner, (Tcl_Event *) ev, TCL_QUEUE_TAIL);
- Tcl_ThreadAlert(rcPtr->owner);
+ Tcl_ThreadQueueEvent(rcPtr->owner, (Tcl_Event *) ev,
+ TCL_QUEUE_TAIL|TCL_QUEUE_ALERT_IF_EMPTY);
}
#endif
@@ -2972,8 +2972,8 @@ ForwardOpToHandlerThread(
* Queue the event and poke the other thread's notifier.
*/
- Tcl_ThreadQueueEvent(dst, (Tcl_Event *) evPtr, TCL_QUEUE_TAIL);
- Tcl_ThreadAlert(dst);
+ Tcl_ThreadQueueEvent(dst, (Tcl_Event *) evPtr,
+ TCL_QUEUE_TAIL|TCL_QUEUE_ALERT_IF_EMPTY);
/*
* (*) Block until the handler thread has either processed the transfer or
diff --git a/generic/tclIORTrans.c b/generic/tclIORTrans.c
index 5c0f47e..ebaa840 100644
--- a/generic/tclIORTrans.c
+++ b/generic/tclIORTrans.c
@@ -2414,8 +2414,8 @@ ForwardOpToOwnerThread(
* Queue the event and poke the other thread's notifier.
*/
- Tcl_ThreadQueueEvent(dst, (Tcl_Event *) evPtr, TCL_QUEUE_TAIL);
- Tcl_ThreadAlert(dst);
+ Tcl_ThreadQueueEvent(dst, (Tcl_Event *) evPtr,
+ TCL_QUEUE_TAIL|TCL_QUEUE_ALERT_IF_EMPTY);
/*
* (*) Block until the other thread has either processed the transfer or
diff --git a/generic/tclNotify.c b/generic/tclNotify.c
index 3d45737..c6ac34e 100644
--- a/generic/tclNotify.c
+++ b/generic/tclNotify.c
@@ -95,8 +95,8 @@ TCL_DECLARE_MUTEX(listLock)
* Declarations for routines used only in this file.
*/
-static void QueueEvent(ThreadSpecificData *tsdPtr,
- Tcl_Event *evPtr, Tcl_QueuePosition position);
+static int QueueEvent(ThreadSpecificData *tsdPtr,
+ Tcl_Event *evPtr, int flags);
/*
*----------------------------------------------------------------------
@@ -392,12 +392,12 @@ Tcl_QueueEvent(
* malloc (Tcl_Alloc), and it becomes the
* property of the event queue. It will be
* freed after the event has been handled. */
- Tcl_QueuePosition position) /* One of TCL_QUEUE_TAIL, TCL_QUEUE_HEAD,
- * TCL_QUEUE_MARK. */
+ int flags) /* One of TCL_QUEUE_TAIL, TCL_QUEUE_HEAD,
+ * TCL_QUEUE_MARK, possibly combined with TCL_QUEUE_ALERT_IF_EMPTY. */
{
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
- QueueEvent(tsdPtr, evPtr, position);
+ (void) QueueEvent(tsdPtr, evPtr, flags);
}
/*
@@ -424,8 +424,8 @@ Tcl_ThreadQueueEvent(
* malloc (Tcl_Alloc), and it becomes the
* property of the event queue. It will be
* freed after the event has been handled. */
- Tcl_QueuePosition position) /* One of TCL_QUEUE_TAIL, TCL_QUEUE_HEAD,
- * TCL_QUEUE_MARK. */
+ int flags) /* One of TCL_QUEUE_TAIL, TCL_QUEUE_HEAD,
+ * TCL_QUEUE_MARK, possibly combined with TCL_QUEUE_ALERT_IF_EMPTY. */
{
ThreadSpecificData *tsdPtr;
@@ -444,7 +444,9 @@ Tcl_ThreadQueueEvent(
*/
if (tsdPtr) {
- QueueEvent(tsdPtr, evPtr, position);
+ if (QueueEvent(tsdPtr, evPtr, flags)) {
+ Tcl_AlertNotifier(tsdPtr->clientData);
+ }
} else {
Tcl_Free(evPtr);
}
@@ -464,7 +466,8 @@ Tcl_ThreadQueueEvent(
* last-in-first-out order.
*
* Results:
- * None.
+ * For TCL_QUEUE_ALERT_IF_EMPTY the empty state before the
+ * operation is returned.
*
* Side effects:
* None.
@@ -472,7 +475,7 @@ Tcl_ThreadQueueEvent(
*----------------------------------------------------------------------
*/
-static void
+static int
QueueEvent(
ThreadSpecificData *tsdPtr, /* Handle to thread local data that indicates
* which event queue to use. */
@@ -481,11 +484,15 @@ QueueEvent(
* malloc (Tcl_Alloc), and it becomes the
* property of the event queue. It will be
* freed after the event has been handled. */
- Tcl_QueuePosition position) /* One of TCL_QUEUE_TAIL, TCL_QUEUE_HEAD,
- * TCL_QUEUE_MARK. */
+ int flags)
+ /* One of TCL_QUEUE_TAIL_EX,
+ * TCL_QUEUE_HEAD_EX, TCL_QUEUE_MARK_EX,
+ * possibly combined with TCL_QUEUE_ALERT_IF_EMPTY */
{
+ int wasEmpty = 0;
+
Tcl_MutexLock(&(tsdPtr->queueMutex));
- if (position == TCL_QUEUE_TAIL) {
+ if ((flags & 3) == TCL_QUEUE_TAIL) {
/*
* Append the event on the end of the queue.
*/
@@ -493,11 +500,12 @@ QueueEvent(
evPtr->nextPtr = NULL;
if (tsdPtr->firstEventPtr == NULL) {
tsdPtr->firstEventPtr = evPtr;
+ wasEmpty = (flags & TCL_QUEUE_ALERT_IF_EMPTY) ? 1 : 0;
} else {
tsdPtr->lastEventPtr->nextPtr = evPtr;
}
tsdPtr->lastEventPtr = evPtr;
- } else if (position == TCL_QUEUE_HEAD) {
+ } else if ((flags & 3) == TCL_QUEUE_HEAD) {
/*
* Push the event on the head of the queue.
*/
@@ -505,9 +513,10 @@ QueueEvent(
evPtr->nextPtr = tsdPtr->firstEventPtr;
if (tsdPtr->firstEventPtr == NULL) {
tsdPtr->lastEventPtr = evPtr;
+ wasEmpty = (flags & TCL_QUEUE_ALERT_IF_EMPTY) ? 1 : 0;
}
tsdPtr->firstEventPtr = evPtr;
- } else if (position == TCL_QUEUE_MARK) {
+ } else if ((flags & 3) == TCL_QUEUE_MARK) {
/*
* Insert the event after the current marker event and advance the
* marker to the new event.
@@ -526,6 +535,7 @@ QueueEvent(
}
}
Tcl_MutexUnlock(&(tsdPtr->queueMutex));
+ return wasEmpty;
}
/*
diff --git a/generic/tclTest.c b/generic/tclTest.c
index 6033fbf..3877369 100644
--- a/generic/tclTest.c
+++ b/generic/tclTest.c
@@ -2184,7 +2184,7 @@ TesteventObjCmd(
"head", "tail", "mark", NULL
};
int posIndex; /* Index of the chosen position */
- static const Tcl_QueuePosition posNum[] = {
+ static const int posNum[] = {
/* Interpretation of the chosen position */
TCL_QUEUE_HEAD,
TCL_QUEUE_TAIL,
diff --git a/generic/tclThreadTest.c b/generic/tclThreadTest.c
index 900af4a..ce9c33a 100644
--- a/generic/tclThreadTest.c
+++ b/generic/tclThreadTest.c
@@ -877,8 +877,7 @@ ThreadSend(
threadEventPtr->event.proc = ThreadEventProc;
Tcl_ThreadQueueEvent(threadId, (Tcl_Event *) threadEventPtr,
- TCL_QUEUE_TAIL);
- Tcl_ThreadAlert(threadId);
+ TCL_QUEUE_TAIL|TCL_QUEUE_ALERT_IF_EMPTY);
if (!wait) {
Tcl_MutexUnlock(&threadMutex);