restricted-workers-0.1.1: Running worker processes under system resource restrictions

Safe HaskellNone

System.Restricted.Worker.Pool

Contents

Description

A non-stripped pooling abstraction that restarts workers Some got has been taken from Pool by bos

Synopsis

Workers Pool

data WorkersPool w Source

A simple pool for workers. Workers are restarted from time to time

mkPoolSource

Arguments

:: MonadIO (WMonad a) 
=> (Int -> WMonad a (Worker a, RestartWorker IO a))

An action that creates a new worker. Takes a unique number as an argument

-> Int

Maximum number of workers in the pool

-> Int

Restart rate (in seconds)

-> WMonad a (WorkersPool a) 

Create a new workers pool

High-level operations on the pool

withWorker :: (MonadBaseControl IO m, MonadBase (WMonad a) m, MonadBaseControl IO (WMonad a), MonadIO (WMonad a)) => WorkersPool a -> ((Worker a, RestartWorker IO a) -> m b) -> m bSource

Like takeWorker + putWorker but takes care of the exception handling for you

Low-level operations on the pool

takeWorker :: (MonadIO (WMonad a), MonadBaseControl IO (WMonad a)) => WorkersPool a -> WMonad a (Worker a, RestartWorker IO a)Source

Take worker from the pool. The caller is responsible for putting the worker back into the pool or destroying it with destroyWorker

putWorker :: WorkersPool a -> (Worker a, RestartWorker IO a) -> IO ()Source

Put the worker back in pool

destroyWorker :: WorkersPool a -> Worker a -> IO ()Source

Destroy a worker. Frees up space in the pool