A WorkerPool manages multiple workers.

## Details

The implementation for a WorkerPool is essentially a container that holds one or more Worker objects, and posesses methods that allow it to instruct them to assign, start, and complete Tasks. It can also check to see if any of the R sessions associated with the Workers have crashed or stalled, and replace them as needed.

## Methods

### Method new()

Create a new worker pool

#### Arguments

x

An integer specifying the index of the worker in the pool.

#### Returns

The corresponding Worker object.

### Method get_pool_state()

Return a summary of the worker pool

#### Arguments

tasks

A TaskList object

#### Returns

Invisibly returns NULL

### Method try_start()

Iterates over Workers in the pool and asks them to start any jobs that the have been assigned but have not yet started. This method is intended to be called by Queue objects.

#### Returns

Invisibly returns NULL

### Method refill_pool()

Check the WorkerPool looking for Workers that have crashed or been shutdown, and replace them with fresh workers.

#### Arguments

grace

Grace period in milliseconds. If a worker process is still running after this period, it will be killed.

#### Returns

This function is called primarily for its side effect. It returns a named character documenting the outcome, indicating the current state of each worker: should be "finished" for all workers. Names denote worker ids.

### Method shutdown_overdue_workers()

Terminate workers that have worked on their current task for longer than a pre-specified time limit.

#### Arguments

deep

Whether to make a deep clone.