summaryrefslogtreecommitdiffstats
path: root/mac/tclMacThrd.c
diff options
context:
space:
mode:
Diffstat (limited to 'mac/tclMacThrd.c')
-rw-r--r--mac/tclMacThrd.c44
1 files changed, 43 insertions, 1 deletions
diff --git a/mac/tclMacThrd.c b/mac/tclMacThrd.c
index eb58865..e4abb26 100644
--- a/mac/tclMacThrd.c
+++ b/mac/tclMacThrd.c
@@ -51,6 +51,12 @@ static int keyCounter = 0;
TclMacThrdData *GetThreadDataStruct(Tcl_ThreadDataKey keyVal);
TclMacThrdData *RemoveThreadDataStruct(Tcl_ThreadDataKey keyVal);
+
+/*
+ * Note: The race evoked by the emulation layer for joinable threads
+ * (see ../win/tclWinThrd.c) cannot occur on this platform due to
+ * the cooperative implementation of multithreading.
+ */
/*
*----------------------------------------------------------------------
@@ -112,7 +118,6 @@ Tcl_CreateThread(idPtr, proc, clientData, stackSize, flags)
int flags; /* Flags controlling behaviour of
* the new thread */
{
-
if (!TclMacHaveThreads()) {
return TCL_ERROR;
}
@@ -136,6 +141,10 @@ Tcl_CreateThread(idPtr, proc, clientData, stackSize, flags)
if ((ThreadID) *idPtr == kNoThreadID) {
return TCL_ERROR;
} else {
+ if (flags & TCL_THREAD_JOINABLE) {
+ TclRememberJoinableThread (*idPtr);
+ }
+
return TCL_OK;
}
@@ -144,6 +153,37 @@ Tcl_CreateThread(idPtr, proc, clientData, stackSize, flags)
/*
*----------------------------------------------------------------------
*
+ * Tcl_JoinThread --
+ *
+ * This procedure waits upon the exit of the specified thread.
+ *
+ * Results:
+ * TCL_OK if the wait was successful, TCL_ERROR else.
+ *
+ * Side effects:
+ * The result area is set to the exit code of the thread we
+ * waited upon.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int
+Tcl_JoinThread(id, result)
+ Tcl_ThreadId id; /* Id of the thread to wait upon */
+ int* result; /* Reference to the storage the result
+ * of the thread we wait upon will be
+ * written into. */
+{
+ if (!TclMacHaveThreads()) {
+ return TCL_ERROR;
+ }
+
+ return TclJoinThread (id, result);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* TclpThreadExit --
*
* This procedure terminates the current thread.
@@ -168,6 +208,8 @@ TclpThreadExit(status)
}
GetCurrentThread(&curThread);
+ TclSignalExitThread ((Tcl_ThreadId) curThread, status);
+
DisposeThread(curThread, NULL, false);
}