class RemiLib::JobPool(T)

Overview

A JobPool allows you to perform work on an enumerable set of things, spreading the work out over a set of fibers.

Defined in:

remilib/concurrency.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(name : String | Nil = nil) #

Creates a new JobPool with the number of workers equal to the number of logical CPUs in the system.


[View source]
def self.new(workers : Int32, name : String | Nil = nil) #

Creates a new JobPool with the given number of workers. This must be greater than zero.


[View source]

Instance Method Detail

def errors : Array(Exception) #

Holds the errors that occurred during #run.


[View source]
def run(things : Enumerable, &block : T -> Nil) #

Runs the pool, assigning one element of things to each job. Each job will call the given block. Any errors that occur during processing will be collected in #errors; #errors is reset each time this is called.


[View source]
def workers : Int32 #

The maximum number of jobs that this JobPool can handle.


[View source]