<i>call for a function that is not thread safe</i> status still Open with 4 other changes
by
.
D 2003-01-25T16:57:48
J icomment Logged\sIn:\sYES\s\nuser_id=95086\n\nMutexes\screated\swith\s"thread::mutex\screate"\sare\s\s\nalready\sin\sthe\sglobal\sscope.\s\nThey\scan\sbe\sused\sfrom\sany\sthread.\sA\smutex\stied\sto\sa\sthread\s\nhas\sno\sreal\sbenefit.\sSo\syou're\sperfectly\sok\swith\sthat.\s\nThe\smutex\sindentifier\sreturned\sby\s"thread::mutex\screate"\scan\s\nbe\spassed\sto\sanother\sthread\sor\sstored\sin\sthe\sthread\sshared\s\nvariable\s(array)\sand\sused\sfrom\sother\sthreads\sas\swell.\s\n\s\nAlso,\sthread::eval\sis\sa\snice\sshortcut\sof\s\n\s\n\s\sthread::mutex\slock\s$mutex\s\n\s\s#\sdo\ssome\sTcl\swork\s\n\s\sthread::mutex\sunlock\s$mutex\s\n\s\nso\syou\scan\sjust\ssay:\s\n\s\n\s\sthread::eval\s-mutex\s$mutex\s{\s\n\s\s\s\s#\sdo\ssome\sTcl\swork\s\n\s\s}\s\n\s\nThe\sbenefit\sis:\syou\scan\snever\sforget\sto\sunlock\sthe\s\nmutex.\sAlso,\sIn\scase\sof\sscript\serror,\sthe\simplementation\s\nguarantees\sthat\sthe\smutex\swill\sbe\sunlocked.\sWithout\sthis\s\nyou\smust\stake\scare\syoursefl\sabout\sunlocking\sthe\smutex\s\nwhich\smay\sprove\scomplicated\sin\ssome\scases.\s\nA\svery\ssimplified\suse\sof\sthread\seval\sis:\s\n\s\sthread.:eval\s{\s\n\s\s\s\s#\sdo\ssome\sTcl\swor\s\n\s\s}\s\n\s\nwhere\sthe\smutex\sis\simplicit\sand\sthis\sway\syou\scan\sbe\ssure\s\nthat\sonly\s*one*\sthread\sat\sa\stime\sin\sthe\sentire\sprocess\scan\s\nrun\sthe\sTcl\scode.\s\n\s\n\s\n
J login vasiljevic
J mimetype text/plain
J username vasiljevic
K 674367ffffffffffffffffffffffffffffffffff
U vasiljevic
Z 74b3e455e2f71e6a9f1084619f0dbace