Updated 2016-02-15 18:07:40 by dbohdan

Daerth, by PYK, 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  edit

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

Daerth Options  edit

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

Station Options  edit

The number of identical stations to create.
A list of consumers to register to the stations.
The value of the -eventmark setting of a station.
The master to register the stations to.
A script to initialize the work environment.
The number of simultaneously-pending transmissions the stations are allowed.
The name of the 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.
The id of the thread to load the station into. This is normally not provided, in which case new stations are created.
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  edit

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 stations that a station 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  edit

The unit tests provide some working examples.