| Store | Cart

Re: [TCLCORE] event-loop, vwait & coroutines

From: Jeff Rogers <dvr...@diphi.com>
Mon, 29 Sep 2014 09:28:40 -0700
Andreas Leitgeb wrote:

> Since Tcl 8.6, we got coroutines, and they could have solved your> problem:>> A coroutine is a "task" that will run given code, which can "yield"> (which is like a pre-mature "return", while holding the current stack)> and later be called again to continue right where it last yielded.>> You can call the coroutine from an event-handler, have it do some> part of its job then yield - thereby going right back to the event-loop> until it gets called again.

The coroutine package in tcllib provides a coroutine-aware version of 
vwait that can be freely nested without blocking other invocations of 
itself, provided it is called from within a coroutine (meaning your 
callbacks/event handlers/bind scripts should be coroutines themselves).

http://core.tcl.tk/tcllib/doc/trunk/embedded/www/tcllib/files/modules/coroutine/tcllib_coroutine.html

-J

------------------------------------------------------------------------------
Slashdot TV.  Videos for Nerds.  Stuff that Matters.
http://pubads.g.doubleclick.net/gampad/clk?id=160591471&iu=/4140/ostg.clktrk
_______________________________________________
Tcl-Core mailing list
Tcl-...@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tcl-core

Recent Messages in this Thread
Jeff Rogers Sep 29, 2014 04:28 pm
Andreas Leitgeb Sep 27, 2014 06:10 pm
Messages in this thread