distributed-process-task-0.1.0: Task Framework for The Cloud Haskell Application Platform

Copyright(c) Tim Watson 2012 - 2013
LicenseBSD3 (see the file LICENSE)
MaintainerTim Watson <watson.timothy@gmail.com>
Stabilityexperimental
Portabilitynon-portable (requires concurrency)
Safe HaskellNone
LanguageHaskell98

Control.Distributed.Process.Task.Queue.BlockingQueue

Description

A simple bounded (size) task queue, which accepts requests and blocks the sender until they're completed. The size limit is applied to the number of concurrent tasks that are allowed to execute - if the limit is 3, then the first three tasks will be executed immediately, but further tasks will then be queued (internally) until one or more tasks completes and the number of active/running tasks falls within the concurrency limit.

Note that the process calling executeTask will be blocked for _at least_ the duration of the task itself, regardless of whether or not the queue has reached its concurrency limit. This provides a simple means to prevent work from being submitted faster than the server can handle, at the expense of flexible scheduling.

Synopsis

Documentation

data BlockingQueue a Source

Instances

type SizeLimit = Int Source

Limit for the number of concurrent tasks.

start :: forall a. Serializable a => Process (InitResult (BlockingQueue a)) -> Process () Source

Start a queue with an upper bound on the # of concurrent tasks.

pool :: forall a. Serializable a => SizeLimit -> Process (InitResult (BlockingQueue a)) Source

Define a pool of a given size.

executeTask :: forall s a. (Addressable s, Serializable a) => s -> Closure (Process a) -> Process (Either ExitReason a) Source

Enqueue a task in the pool and block until it is complete.

stats :: forall s. Addressable s => s -> Process (Maybe BlockingQueueStats) Source

Fetch statistics for a queue.