Tcl Source Code

Ticket Change Details
Login
Overview

Artifact ID: 40e85b6fd7ef453ea6e739b22486d34867de3679b903eb60c421a59bdb0fc308
Ticket: de232b49f26da1c18e07513d4c7caa203cd27910
write-only nonblocking refchan and Tcl internal buffers
User & Date: apnadkarni 2024-03-31 15:49:13
Changes

  1. icomment:
    As it stands, there is another problem with the current implementation. If run in wish, it freezes the GUI as the idle events never get to run. I suspect the write event keeps getting queued after an interval of SYNTHETIC_EVENT_TIME which happens to be 0 which means the event queue is never drained. Test io-44.6 which tests the implementation never actually tests that other events are not blocked.
    
    The attached script illustrates this. This is essentially a modified version of io-44.6.
    
    With tclsh 8.6, the time is printed every second
    
    ```
    c:\src\tcltk\wip\tcl\tests>tclsh86t ..\tests\refchan-async-test.tcl
    1711899031
    1711899032
    1711899033
    1711899034
    1711899035
    ^C
    ```
    
    With 9.0 however, after the initial invocation the time is never printed
    
    ```
    c:\src\tcltk\wip\tcl\tests>d:\tcl\90\x64-debug\bin\tclsh90.exe ..\tests\refchan-async-test.tcl
    1711899100
    ^C
    ```
    
    The branch apn-bug-de232b49f2 works properly
    
    ```
    c:\src\tcltk\wip\tcl\tests>d:\tcl\wip\x64-debug\bin\tclsh90.exe ..\tests\refchan-async-test.tcl
    1711899197
    1711899198
    1711899199
    1711899200
    ^C
    ```
    
    Now could one change SYNTHETIC_EVENT_TIME to something other than 0? The comment there says *Must be zero or bad things tend to happen*. Could it possibly do the equivalent of "after idle after 0"? I suspect this will have the same undesirable effect as changing SYNTHETIC_EVENT_TIME and anyways feels like a patch for a patch for fundamentally broken design.
    
    The above illustrates tclsh but the same effect is seen with wish.
    
    ```
    d:\tcl\wip\x64-debug\bin\wish90.exe ..\tests\refchan-async-test.tcl
    ```
    
    pops up a text widget that can be edited. On the other hand, with the existing 9.0, the text widget is shown but no characters are displayed when you type and the GUI appears frozen.
    
    This. Polling. Based. Design. For. Events. Is. Just. Plain. Wrong.
    
    /Ashok
    
  2. login: "apnadkarni"
  3. mimetype: "text/x-markdown"