diff options
author | Joe Mistachkin <joe@mistachkin.com> | 2013-10-28 23:39:40 (GMT) |
---|---|---|
committer | Joe Mistachkin <joe@mistachkin.com> | 2013-10-28 23:39:40 (GMT) |
commit | 6c8ec5a8fe406cf53341424e1529c9b0794b03ee (patch) | |
tree | beb6424449783d7a9c84509ad47109c9e988e1fc /generic/tclThread.c | |
parent | 275aef21ecc230467a7849b792c43881b58557ff (diff) | |
download | tcl-6c8ec5a8fe406cf53341424e1529c9b0794b03ee.zip tcl-6c8ec5a8fe406cf53341424e1529c9b0794b03ee.tar.gz tcl-6c8ec5a8fe406cf53341424e1529c9b0794b03ee.tar.bz2 |
Add experimental new Tcl API Tcl_UnsetThreadData.
Diffstat (limited to 'generic/tclThread.c')
-rw-r--r-- | generic/tclThread.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/generic/tclThread.c b/generic/tclThread.c index 8384107..83c7f8c 100644 --- a/generic/tclThread.c +++ b/generic/tclThread.c @@ -104,6 +104,70 @@ Tcl_GetThreadData( /* *---------------------------------------------------------------------- * + * Tcl_UnsetThreadData -- + * + * This function finalizes and deallocates a chunk of thread local + * storage. + * + * Results: + * None. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +void +Tcl_UnsetThreadData( + Tcl_ThreadDataKey *keyPtr, /* Identifier for the data chunk */ + int size, /* Size of storage block */ + int all) /* Unset for all threads? */ +{ +#ifdef TCL_THREADS + void *result = TclpThreadDataKeyGet(keyPtr); + if (all) { + TclpThreadDataKeyUnsetAll(keyPtr, 1 /* free */); + } else { + TclpThreadDataKeyUnset(keyPtr, 1 /* free */); + } +#else + void *result = *keyPtr; + TclThreadFreeData(result, size); + ForgetSyncObject((char *) keyPtr, &keyRecord); +#endif /* TCL_THREADS */ +} + +/* + *---------------------------------------------------------------------- + * + * TclThreadFreeData -- + * + * This function deallocates a chunk of thread local storage. + * + * Results: + * None. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +void +TclThreadFreeData( + void *blockPtr, /* Pointer to thread local data chunk */ + int size) /* Size of storage block */ +{ + if (blockPtr != NULL) { + memset(blockPtr, 0, (size_t) size); + ckfree((char *) blockPtr); + } +} + +/* + *---------------------------------------------------------------------- + * * TclThreadDataKeyGet -- * * This function returns a pointer to a block of thread local storage. |