Subject: Re: Tcl_Eval and reentrancy - DN [1]
Scott Redman <redman@scriptics.com> - 08 Apr 1999 - comp.lang.tcl
David Gravereaux wrote: > > Scott Redman <redman@scriptics.com> wrote: > > >DO NOT USE 8.0.x with multiple threads! It is NOT thread-safe. > > Scott, I do it all the time. > > Rather than expect 8.0.5 to be thread-safe, I sync my own threads to > work with Tcl's singlethreaded core. Which for me, works fine. I'm > quite happy with a singlethreaded core. > > * David Gravereaux * > Tomahawk Software Group > Mahalo Aloha from Maui, Hawai'i (for comp.lang.tcl readers) This will work, but you need to be careful not to call the interpreter or _any_ Tcl API fn's from more than one thread at a time (you need to guard ALL calls to Tcl_* with mutexes or semaphores from your code). Another way (8.0.x) is to guarantee that only one thread ever calls the Tcl_* functions. Using 8.0.4, I wrote a simple queue where other threads placed scripts to execute in the interepreter into the queue, and I used events (Win32's CreateEvent()) to synchronize. Data returned was always copied as a string and the return value. This worked fine. But, 8.1 has this functionality built-in, plus it allows you to keep the result in TclObj form and call Tcl_ functions. If you haven't already worked around the lack of thread safety in 8.0.x, I'd highly recommend using 8.1 with --enable-threads turned on (on Windows, change the makefile.vc to uncomment the line "THREADDEFINES=-DTCL_THREADS=1"). -- Scott Redman
Last modified
1999-09-27
1999-09-27
(195.108.246.50)
Note: you are looking at
the snapshot of an old wiki
- much of this information
is likely to be very outdated
