Channel

cispy/channel~ Channel

Source:

A channel, used by processes to communicate with one another.

For each operation, the channel first tests to see if there's a corresponding operation already queued (i.e., if we're doing a put that there's a queued take and vice versa). If there is, that corresponding operation is unblocked and both operations complete. If not, the operation is queued to wait for a corresponding operation. The process or that created the operation then blocks.

The channel can be backed by a buffer, though it is not by default. If a buffer is in place, and that buffer is not full, then the process that created an operation that has to be queued is not blocked.

This channel object supports transformations, assuming that they follow the rather informal protocol created by a few transducer library authors to allow them to interoperate. The support must be explicitly created because the normal method of making an object support transformations won't work here. This method is to create a new object and add the transformed values to it - but for a channel, we need to replace the values on the channel with their transformed values, in the same order even in a multi-process environment. Thus transformations happen in place.

Transformations are applied before the value is queued, so even if there is a corresponding operation ready to go, the transformation still happens. Also, transformations require that the channel be buffered (this buffer is what is sent to the transformer's reduction step function); trying to create a channel with a transformer but without a buffer will result in an error being thrown.

This is the object that is returned from a call to chan(). However, this object is intended to be used as a value to pass to channel operation functions; the function properties on this object are low-level.

Members

(readonly) buffered :boolean

Source:

Determines whether this channel has a buffer.

Type:
  • boolean

(readonly) closed :boolean

Source:

Determines whether this channel has been closed.

Type:
  • boolean

(readonly) timeout :boolean

Source:

Determines whether this channel is a timeout channel. A timeout channel is one that, when created, was given a certain amount of time before automatically closing. The channel itself is not aware of how long it has until it is closed.

Type:
  • boolean