module

Concur

Instance methods

every(t : Time::Span, name = nil, buffer_size = 0, terminate = Channel(Time).new, &block : -> T) : Channel(T) forall T

Returns a channel that will receive the value returned by block at intervals of at least t between one call and the other.

If an exception is raised while running a block, then the returned channel will be closed.

An optional channel terminate can be passed to the method. Sending an object to this channel - or closing it - will halt the sending of new values as soon as any outstanding run of block is completed and close the returned channel.

NOTE: Only a single instance of block can be running at any given time. If the block takes a time x to complete, then the time between two runs of block will be at least t + x.

Source
flatten(in_stream : Channel(Enumerable(K)), name = nil, buffer_size = 0) : Channel(K) forall K

Returns a channel that will receive each element of the enumerables received by in_stream, one at a time.

If in_stream is closed, then the returned stream will also be closed once in_stream has been emptied.

Source
source(input : Enumerable(T), name = nil, buffer_size = 0) : Channel(T) forall T

Returns a channel that will receive each element in the given enumerable, and then close.

Source
source(initial_state : S, name = nil, buffer_size = 0, &block : S -> Tuple(S, V)) forall S, V

Returns a channel that will receive each value generated by recursively calling block, starting from the given initial_state.

If an exception is raised while running a block, then the returned channel will be closed.

NOTE: block is a function returning a tuple composed of the next state to be passed to the block and the next value to be received by the returned channel.

Source