Skip to content
Tcl Source Code Artifact [df9cd8015c]
Login

Artifact [df9cd8015c]

Artifact df9cd8015c5ca063888d3a5d7bf3301a7a5b9dec110260da40708f809b89419c:

Ticket change [df9cd8015c] - Closed ticket [d215ef73bb993033|d215ef73bb]: <i>How to detect &quot;unknown&quot; command inside the thread script in proc unknown of init.tcl file</i> plus 5 other changes by sebres on 2021-03-10 13:31:21.
D 2021-03-10T13:31:21.861
J closedate 2459284.06344745
J closer sebres
J icomment <blockquote><i>>\sCan\swe\sdetect\sin\sthis\sproc\s"proc\sunknown\sargs"\sthat\sthis\s"unknown"\scommand\sis\scoming\sfrom\sthread\sscript?</i></blockquote>\r\n\r\nNot\sreally\s(in\sdirect\sway).\sTcl\sinterpreter\s(as\swell\sas\sunknown\sor\salso\sother\shandlers)\sdo\snot\simply\susage\sof\sany\sthread\sfacilities,\sneither\sdistinguish\sthe\sthreads\s(indirectly\sthe\sinterpreter\sknows\sonly\sits\sown\sthread\swhere\sit\sbelongs\sto).<br/>\r\nFile\s<code>init.tcl</code>\sis\sloaded\sin\severy\sinterpreter\s(regardless\sthe\sthread)\sif\sit\sgets\screated\s(initialized).\r\n\r\nBut\sthis\sis\soccured\sin\smain\sthread\sas\sfirst...\s<br/>\r\nSo\seither\syou\swould\ssave\sthe\sID\sof\sthe\smain\sthread\sand\scompare\sit\sinside\syour\sunknown\shandler\slike\sthis:\r\n<code><pre\sstyle="padding-left:10pt">\r\n#\ssomewhere\sin\smain\sthread\s(or\seven\sin\sinit.tcl):\r\nif\s{![tsv::exists\sthreads\smain]}\s{\r\n\s\stsv::set\sthreads\smain\s[thread::id]\r\n}\r\n...\r\n#\sin\sunknown\shandler:\r\nif\s{[tsv::get\sthreads\smain]\sne\s[thread::id]}\s{\r\n\s\sputs\s"this\sis\shelper\sthread"\r\n}\r\n</pre></code>\r\nOr\syou\swould\sset\ssome\smarker\sfor\sthis\sthread\s(like\shere\svariable\s<code>::helper_thread</code>):\r\n<code><pre\sstyle="padding-left:10pt">\r\n#\sin\sunknown\shandler:\r\nif\s{[info\sexists\s::helper_thread]\s&&\s$::helper_thread}\s{\r\n\s\sputs\s"this\sis\shelper\sthread"\r\n}\r\n\r\nthread::create\s{\r\n\s\s#\smark\sthread\sas\sa\shelper\sthread:\r\n\s\sset\s::helper_thread\s1\r\n\s\s...\r\n\s\sunknown_command\r\n}\r\n</pre></code>\r\nJust\snote\sthat\sin\sthis\scase\sfile\s<code>init.tcl</code>\sis\scalled\sbefore\sinit-script\sof\s<code>thread::create</code>\sgets\scalled,\sso\ssetting\sof\s<code>set\s::helper_thread\s1</code>\smay\sbe\stoo\slate,\sif\sunknown\shandler\sgets\sinvoked\sduring\ssome\sinitialization\sprocess\s(inside\s<code>init.tcl</code>\sinvocation).
J login sebres
J mimetype text/x-fossil-wiki
J status Closed
K d215ef73bb9930338f44b8e3fa28e188c7597c21
U sebres
Z 975850b1c5f6521318b9d375df9c5825