Tcl Library Source Code

Documentation
Login
Bounty program for improvements to Tcl and certain Tcl packages.


[ Main Table Of Contents | Table Of Contents | Keyword Index | Categories | Modules | Applications ]

NAME

coroutine - Coroutine based event and IO handling

Table Of Contents

SYNOPSIS

package require Tcl 8.6
package require coroutine 1.3

coroutine::util after delay
coroutine::util await varname...
coroutine::util create arg...
coroutine::util exit ?status?
coroutine::util gets chan ?varname?
coroutine::util gets_safety chan limit varname
coroutine::util global varname...
coroutine::util puts ?-nonewline? channel string
coroutine::util read -nonewline chan ?n?
coroutine::util socket ?options...? host port
coroutine::util update ?idletasks?
coroutine::util vwait varname

DESCRIPTION

The coroutine package provides coroutine-aware implementations of various event- and channel related commands. It can be in multiple modes:

  1. Call the commands through their ensemble, in code which is explicitly written for use within coroutines.

  2. Import the commands into a namespace, either directly, or through namespace path. This allows the use from within code which is not coroutine-aware per se and restricted to specific namespaces.

A more agressive form of making code coroutine-oblivious than point 2 above is available through the package coroutine::auto, which intercepts the relevant builtin commands and changes their implementation dependending on the context they are run in, i.e. inside or outside of a coroutine.

API

All the commands listed below are synchronous with respect to the coroutine invoking them, i.e. this coroutine blocks until the result is available. The overall eventloop is not blocked however.

Bugs, Ideas, Feedback

This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category coroutine of the Tcllib Trackers. Please also report any ideas for enhancements you may have for either package and/or documentation.

When proposing code changes, please provide unified diffs, i.e the output of diff -u.

Note further that attachments are strongly preferred over inlined patches. Attachments can be made by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar.

KEYWORDS

after, channel, coroutine, events, exit, gets, global, green threads, read, threads, update, vwait

CATEGORY

Coroutine

COPYRIGHT

Copyright © 2010-2015 Andreas Kupries