Skip to content
Tcl Source Code Artifact [7541238afe]
Login

Artifact [7541238afe]

Artifact 7541238afe87c06a743e5978636cd3076b2b0de9f3f0df6cd0fcfde975045cc6:

Ticket change [7541238afe] - Ticket [39680865953cce4f|3968086595] <i>Basic nonblocking write-only refchan hangs</i> status still Open with 3 other changes by apnadkarni on 2024-08-14 10:50:26.
D 2024-08-14T10:50:26.948
J icomment Nathan,\sa\sworking\sversion\sof\syour\schannel\simplementation\sis\sbelow\sbut\sfirst...\r\n\r\n*Nathan\swrote:\sThis\sfix\sis\snot\sthe\ssame\sas\sthose\sthat\swere\spreviously\sargued,\sand\sthe\sexample\sthat\sdemonstrates\sthe\sissue\sis\salso\snot\sthe\ssame.\sThe\sprevious\sarguments\swere\sabout\s1)\swhether\san\sasynchronous\schannel\sshould\simmediately\ssignal\swritable\swhen\sa\schannel\sis\sopened,\sand\s2)\swhether\spostevent\sis\sasynchronous.*\r\n\r\nNot\sso.\sWhile\s2)\swas\sa\smatter\sof\srequiring\sa\sTIP\sfor\sincompatible\schanges\sto\sa\spublic\sAPI\swhere\sit\scould\sbe\sdiscussed,\s1)\swas\sonly\sa\ssymptom\sof\sa\slarger\sissue\s-\scontinuous\sgeneration\sof\s"write"\sevents\swithout\sknowledge\sof\sactual\schannel\sstate,\ssomething\swhich\scompletely\sdefeats\sthe\spurpose\sof\sevent-based\sI/O\sturning\sit\sinto\sa\sdisguised\spolling\smodel.\sThe\scommit\sunder\sdiscussion\sraises\sthe\ssame\sfears\spending\sa\sthorough\sreview,\sleave\saside\sthe\squestion\sof\swhether\sthose\schanges\sare\seven\sneeded.\r\n\r\n*Nathan\swrote:\sThe\score\steam\sshould\stake\scare\snot\sto\sbecome\sa\sbottleneck\sto\sneeded\scontributions.*\r\n\r\nWhile\sthere\swill\sbe\ssome\sdelay,\sI\sam\safraid\sthe\stime\swasted\sthis\syear\schasing\sdown\sand\sreverting\sor\sfixing\scommits\sthat\smade\sit\sin\swithout\sreview\sis\san\sorder\sof\smagnitude\shigher.\r\n\r\nGetting\sto\syour\ssample\sscript,\sbelow\sis\sa\sworking\sversion\sof\sa\sfunctionally\ssimilar\srefchan.\sThe\simplementation\sis\sbased\son\sAku's\soriginal\spaper.\sNote\sthe\srefchan\s*implementation*\smay\sdiffer\sbut\sI\sbelieve\sthe\s*functionality*\sand\s*user*\stest\scode\sis\sthe\ssame\sas\syour\srefchan.\sFeel\sfree\sto\scheck\sthat\sbut\smy\sguess\sis\sthat\syour\srefchan\simplementation\shas\sa\sbug\sor\sis\sincomplete\sas\sis\sthe\scase\sin\sthe\stwo\stickets\syou\sinsist\son\sreopening.\r\n\r\n```\r\nnamespace\seval\src\s{\r\n\s\s\s\snamespace\sensemble\screate\r\n\s\s\s\snamespace\sexport\s*\r\n\s\s\s\s#\sChange\sto\staste\sdepending\son\show\smuch\sCPU\syou\swant\sto\shog\r\n\s\s\s\svariable\sdelay\s0\r\n\r\n\s\s\s\sproc\sfinalize\s{chan\sargs}\s{\r\n\s\s\s\s\s\s\s\snamespace\supvar\sc_$chan\stimer\stimer\sbuffer\sbuffer\r\n\s\s\s\s\s\s\s\scatch\s{after\scancel\s$timer}\r\n\s\s\s\s\s\s\s\sputs\s"Finalize:\sHave\s[string\slength\s$buffer]\sbytes."\r\n\s\s\s\s\s\s\s\snamespace\sdelete\sc_$chan\r\n\s\s\s\s}\r\n\r\n\s\s\s\sproc\sinitialize\s{chan\sargs}\s{\r\n\s\s\s\s\s\s\s\snamespace\seval\sc_$chan\s{}\r\n\s\s\s\s\s\s\s\snamespace\supvar\sc_$chan\swatching\swatching\stimer\stimer\sbuffer\sbuffer\r\n\s\s\s\s\s\s\s\sset\swatching\s{}\r\n\s\s\s\s\s\s\s\sset\sbuffer\s{}\r\n\s\s\s\s\s\s\s\sreturn\s{finalize\sinitialize\swatch\swrite}\r\n\s\s\s\s}\r\n\r\n\s\s\s\sproc\swatch\s{chan\sspec}\s{\r\n\s\s\s\s\s\s\s\snamespace\supvar\sc_$chan\swatching\swatching\r\n\s\s\s\s\s\s\s\sset\swatching\s$spec\r\n\s\s\s\s\s\s\s\supdate\s$chan\r\n\s\s\s\s}\r\n\r\n\s\s\s\sproc\swrite\s{chan\sdata}\s{\r\n\s\s\s\s\s\s\s\snamespace\supvar\sc_$chan\sbuffer\sbuffer\r\n\s\s\s\s\s\s\s\sappend\sbuffer\s$data\r\n\s\s\s\s\s\s\s\sreturn\s[string\slength\s$data]\r\n\s\s\s\s}\r\n\r\n\s\s\s\sproc\supdate\s{chan}\s{\r\n\s\s\s\s\s\s\s\snamespace\supvar\sc_$chan\swatching\swatching\stimer\stimer\r\n\s\s\s\s\s\s\s\svariable\sdelay\r\n\s\s\s\s\s\s\s\scatch\s{after\scancel\s$timer}\r\n\s\s\s\s\s\s\s\sif\s{"write"\sin\s$watching}\s{\r\n\s\s\s\s\s\s\s\s\s\s\s\sset\stimer\s[after\sidle\safter\s$delay\s\\\r\n\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s[namespace\scode\s[list\spost\s$chan]]]\r\n\s\s\s\s\s\s\s\s}\r\n\s\s\s\s}\r\n\r\n\s\s\s\sproc\spost\s{chan}\s{\r\n\s\s\s\s\s\s\s\svariable\sdelay\r\n\s\s\s\s\s\s\s\snamespace\supvar\sc_$chan\swatching\swatching\stimer\stimer\r\n\s\s\s\s\s\s\s\sif\s{"write"\sin\s$watching}\s{\r\n\s\s\s\s\s\s\s\s\s\s\s\sset\stimer\s[after\sidle\safter\s$delay\s\\\r\n\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s[namespace\scode\s[list\spost\s$chan]]]\r\n\s\s\s\s\s\s\s\s\s\s\s\schan\spostevent\s$chan\swrite\r\n\s\s\s\s\s\s\s\s}\r\n\s\s\s\s}\r\n}\r\n\r\nset\schan\s[chan\screate\swrite\s[namespace\swhich\src]]\r\nchan\sconfigure\s$chan\s-blocking\s0\r\ncoroutine\sc1\sapply\s[list\schan\s{\r\n\s\s\s\safter\s0\s[list\s[info\scoroutine]]\r\n\s\s\s\syield\r\n\s\s\s\schan\sevent\s$chan\swritable\s[list\s[info\scoroutine]]\r\n\s\s\s\swhile\s{[incr\si]\s<\s1000000}\s\s{\r\n\s\s\s\s\s\s\s\syield\r\n\s\s\s\s\s\s\s\sputs\s[list\swriting\sto\s$chan\s$i]\r\n\s\s\s\s\s\s\s\sputs\s$chan\s$i\r\n\s\s\s\s}\r\n\s\s\s\sset\s[namespace\scurrent]::done\s1\r\n}\s[namespace\scurrent]]\s$chan\r\nvwait\s[namespace\scurrent]::done\r\nclose\s$chan\r\n```\r\n\r\nFor\sexplanation\sof\sabove,\splease\ssee\sAku's\spaper.
J login apnadkarni
J mimetype text/x-markdown
K 39680865953cce4fa7187d3613ff7707302d31a6
U apnadkarni
Z 011c09905ce60f6be5b2b58ff4dd9c3c