class

Commander(T)

Inherits Reference < Object

A commander can dispatch blocks to run concurrently. The caller can dictate the number of concurrent jobs by passing in a max concurrency at the time of initialization.

Constants

DEFAULT_RESULT_CAPACITY = 1024

Constructors

new(result_capacity, max_concurrency)

Initializes a new instance of this class with the given max concurrency. Max concurrency will dictate the number of concurrent jobs. All dispatched job will run concurrently if max concurrency is set to zero.

Source
new

Initializes a new instance with the default result capacity, and no concurrency limit.

Source

Class methods

with_capacity(result_capacity)

Creates a new instance with the given result capacity, without concurrency limit.

Source
with_concurrency_limit(max_concurrency)

Creates a new instance with a concurrency limit, using the default result capacity.

Source

Instance methods

collect

Collects the result of the dispatched calls. This function will only return once all the dispatched calls are finished. This function will raise the first error that it received from any of the dispatched calls.

Source
collect_tries

Collects the result of the dispatched calls. This function will only return once all the dispatched calls are finished. This function does not raise any exception from the dispatched calls. The exceptions are wrapped in Try(T), with has_result set to false.

Source
dispatch

Dispatches the given block to run in a new fiber. Note: the spawned fiber will block if max concurrency is hit, and will only proceed to invoke the given block when previously spawned fibers finishes.

Source
size

Gets the number of dispatched jobs

Source

Nested types