Version 0 of Daerth

Updated 2015-04-13 04:15:46 by pooryorick

Daerth is Eeeevvilll, as in frueets of the deeeviilll, and it triumphs over Good! Use it to control minions of asynchronous threaded pipelined backpressure-mediated death stations, to dominate rogue cores and to exploit computational resources throughout the galaxy.

Synopsis

daerth::new ?master? ?prefix? ?producers? ?threadid?
daerth::station::new ?count? ?consumers? ?eventmark? ?master? ?init? ?limit? ?prefix? ?script? ?threadid? ?work?

Daerth Options

master
The id of the thread that initiates the master.
prefix
The name of the namespace into which to load the system. All workstations registered with a master must use the same namespace name.
producers
A list of stations serving as producers.

Station Options

count
The number of identical stations to create.
consumers
A list of consumers to register to the stations.
eventmark
The value of the -eventmark setting of a station.
master
The master to register the stations to.
init
A script to initialize the work environment.
limit
The number of simultaneously-pending transmissions the stations are allowed.
prefix
The name of te namespace into which to load the station. This must be the same name as that of the master to which the station will be registered.
threadid
The id of the thread to load the station into. This is normally not provided, in which case new stations are created.
work
A script that processes incoming and produces outgoing messages. When it is called, $data contains a list of incoming messages. It may execute feed to transmit messages, and done to complete. It is a component of a coroutine, so it maintains state throught the operational lifetime of the station.

Description

Daerth was inspired by a conversation in the Tcl Chatroom in 2015-04 about the thread package. The system contemplates a scenario in which each station is a thread, some stations are producers, others are filters, others are consumers, and one is the master. Less hierarchical arrangements have not been attempted, but may also work.

Each station may produce messages for and/or consume messages from other stations. Two settings are provided to manage congestion in the pipelines. The standard -eventmark configuration limits the queue of incoming calls from other threads, and another setting, 'limit, limits the number of asynchronous posts to other threads that a thread may have simultaneously pending.

Each station may operate in one of two dispatch modes: multi or balance. In multi mode, each message is dispatched to all consumers. In balance mode, each message is sent to one of the least busy consumers.

With the default error propagation system, an error on any thread will cause the entire network of stations to halt. To avoid this, catch errors in the work script of the stations.

Daerth requires Thread version 2.7.3 (not yet released), or some other version of Thread that includes a fix for the issue -eventmark + thread::send -async == deadlock .

Daerth is located in the ycl repository, but doesn't actually depend on anything else in ycl.

Examples

The unit tests provide some working examples.