Overview
| Artifact ID: | 2d3c9b8117891766607e9a75e8e3c9483ae1afce4a5ec2da4b1d3866a065c3ee |
|---|---|
| Ticket: | de232b49f26da1c18e07513d4c7caa203cd27910
write-only nonblocking refchan and Tcl internal buffers |
| User & Date: | pooryorick on 2019-04-26 20:53:55 |
Changes
- assignee changed to: "nobody"
- closer changed to: "nobody"
- cmimetype changed to: "text/x-fossil-wiki"
- comment changed to:
Given the following write-only refchan, the coroutine attempting to use such a channel yields once and writes to the channel once. After the coroutine yields a second time, the channel never becomes writable again and the coroutine is never entered again: <code><verbatim> namespace eval refchan { namespace ensemble create namespace export * proc finalize {chan args} { namespace delete c_$chan } proc initialize {chan args} { namespace eval c_$chan {} namespace upvar c_$chan watching watching set watching {} list finalize initialize seek watch write } proc watch {chan args} { namespace upvar c_$chan watching watching foreach arg $args { switch $arg { write { if {$arg ni $watching} { lappend watching $arg } chan postevent $chan $arg } } } } proc write {chan args} { chan postevent $chan write return 1 } } after 0 [list coroutine c1 apply [list {} { set chan [chan create write refchan] chan configure $chan -blocking 0 chan event $chan writable [list [info coroutine]] for {set i 0} {$i < 10} {incr i} { yield puts $chan hello } set ::done 1 }]] vwait done </verbatim></code> The problem is that <code>tclIO.c/Write</code> adds the value from the first write into an internal buffer but takes no actions that result in another call to <code>Tcl_NotifyChannel</code>. In particular, the "write" command of the reference channel is never called because the result of <code>IsBufferFull</code> is "false". - is_private changed to: "0"
- login: "pooryorick"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- severity changed to: "Minor"
- status changed to: "Open"
- submitter changed to: "pooryorick"
- subsystem changed to: "- New Builtin Commands"
- title changed to:
write-only nonblocking refchan and Tcl internal buffers
- type changed to: "Bug"