Overview
| Artifact ID: | a63e290da35df372e587b96ea3557f693fa38da0 |
|---|---|
| Ticket: | 674367ffffffffffffffffffffffffffffffffff
call for a function that is not thread safe |
| User & Date: | vasiljevic on 2003-01-25 16:57:48 |
Changes
- icomment:
Logged In: YES user_id=95086 Mutexes created with "thread::mutex create" are already in the global scope. They can be used from any thread. A mutex tied to a thread has no real benefit. So you're perfectly ok with that. The mutex indentifier returned by "thread::mutex create" can be passed to another thread or stored in the thread shared variable (array) and used from other threads as well. Also, thread::eval is a nice shortcut of thread::mutex lock $mutex # do some Tcl work thread::mutex unlock $mutex so you can just say: thread::eval -mutex $mutex { # do some Tcl work } The benefit is: you can never forget to unlock the mutex. Also, In case of script error, the implementation guarantees that the mutex will be unlocked. Without this you must take care yoursefl about unlocking the mutex which may prove complicated in some cases. A very simplified use of thread eval is: thread.:eval { # do some Tcl wor } where the mutex is implicit and this way you can be sure that only *one* thread at a time in the entire process can run the Tcl code. - login: "vasiljevic"
- mimetype: "text/plain"
- username: "vasiljevic"