Skip to content
Tcl Source Code History Of Ticket 570cb6afea12bc13
Login

History Of Ticket 570cb6afea12bc13

Artifacts Associated With Ticket 570cb6afea12bc13

  1. Ticket change [3726fbda7e] (rid 190769) by arvind29 on 2021-01-06 15:18:31:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/plain"
    4. comment initialized to:
      Below "vwait x " is not getting hang. Why ?
      
      #tcl commands
      set x {}
      after 100 lappend x a
      after 200 lappend x b
      after 300 lappend x c
      after 700
      vwait x
      set x
      
    5. foundin initialized to: "8.6.8"
    6. is_private initialized to: "0"
    7. login: "arvind29"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "24b6332679e5f96732dab3b9d46f1f0d512b2551"
    10. resolution initialized to: "None"
    11. severity initialized to: "Critical"
    12. status initialized to: "Open"
    13. submitter initialized to: "arvind29"
    14. subsystem initialized to: "- New Builtin Commands"
    15. title initialized to: "Not getting expected outut."
    16. type initialized to: "Bug"
  2. Ticket change [da395d3e1a] (rid 190775) by jan.nijtmans on 2021-01-06 16:07:28:

    1. assignee changed to: "jan.nijtmans"
    2. closedate changed to: "2459221.17185858"
    3. closer changed to: "jan.nijtmans"
    4. icomment:
      The "after" commands are only executed when an event loop is running. In your case, the "vwait" runs the event loop, so that's when the lappends happen.
      
      If you put an "update" just before the vwait, it hangs as expected:
      
      #tcl commands
      set x {}
      after 100 lappend x a
      after 200 lappend x b
      after 300 lappend x c
      after 700
      update
      vwait x
      set x
      
    5. login: "jan.nijtmans"
    6. mimetype: "text/x-fossil-wiki"
    7. resolution changed to: "Works For Me"
    8. severity changed to: "Cosmetic"
    9. status changed to: "Closed"
  3. Ticket change [9319dae2ac] (rid 190776) by sebres on 2021-01-06 16:23:16:

    1. closedate changed to: "2459221.18282566"
    2. closer changed to: "sebres"
    3. icomment:
      <code>after 700</code> is a simple sleep (no events executed during this sleep process at all); if you want that 3 timer events (100, 200 and 300ms) going executed during this sleep, you have to implement it:
      <ul>
      <li> either using other vwait:<code><pre>
        <b style="color:red">- after 700</b>
        <b style="color:green">+ after 700 {set ::to 1}; vwait ::to</b>
      </pre></code>
      </li>
      By the way there is also an enhancement RFE [fdfbd5e10] introducing timeout by vwait, e. g. <code>vwait 700 _</code> for exactly such purposes.<br/>
      <li> or using some cycle from now up to now+700ms, with update (and small after to avoid busy wait) inside the cycle
      </li>
      </ul>
      
    4. login: "sebres"
    5. mimetype: "text/x-fossil-wiki"
  4. Ticket change [114b6ec49c] (rid 190777) by arvind29 on 2021-01-06 17:00:13:

    1. closedate changed to: "2459221.20849206"
    2. closer changed to: "arvind29"
    3. icomment:
      My query is...
      I have configured the TCL with -enable_thread flag and run below TCL commands.
      should it be hang or not ?
      
      
      #tcl commands
      set x {}
      after 100 lappend x a
      after 200 lappend x b
      after 300 lappend x c
      after 700
      vwait x
      set x
      
    4. login: "arvind29"
    5. mimetype: "text/plain"
  5. Ticket change [da187548cd] (rid 190778) by arvind29 on 2021-01-06 17:04:06:

    1. closer changed to: "nobody"
    2. login: "arvind29"
    3. mimetype: "text/plain"
    4. status changed to: "Open"
  6. Ticket change [e0d3d2d8d5] (rid 190782) by sebres on 2021-01-06 18:37:53:

    1. closedate changed to: "2459221.27631346"
    2. closer changed to: "sebres"
    3. icomment:
      <blockquote><i>> I have configured the TCL with -enable_thread flag and run below TCL commands.</i></blockquote>
      
      option "-enable_thread" (as well as threads themselves) has nothing to do with an event cycle (you handle quasi single-threaded here), this option just allows to use threads in tcl at all (e. g. thread module or some system threads, so the library is usable with threads).
      
      Also don't confuse tcl with other langs using GIL (for example with python), every tcl interpreter belong to exactly one main thread, whom is allowed to execute code in this interpreter. There are few exceptions in tcl world, which could act across the threads or are shared between the workers.
      
      Event cycle is to consider single-threaded (basically this is true in every language).
      
      <blockquote><i>> should it be hang or not ?</i></blockquote>
      
      yes, this is fully expected behavior, because as already said <code>after 700</code> does just a sleep for current thread, the events are not executed at all; read [https://www.tcl.tk/man/tcl8.6/TclCmd/after.htm|documentation] or [https://wiki.tcl-lang.org/page/Tcl+event+loop|wiki :: Tcl event loop] for more info.
      
      Regarding the threads, you may take a look at [https://www.tcl.tk/man/tcl8.6/ThreadCmd/contents.htm|thread package].
      
    4. login: "sebres"
    5. mimetype: "text/x-fossil-wiki"
    6. status changed to: "Closed"