Copyright | (c) Tim Watson 2012 - 2013 |
---|---|
License | BSD3 (see the file LICENSE) |
Maintainer | Tim Watson <watson.timothy@gmail.com> |
Stability | experimental |
Portability | non-portable (requires concurrency) |
Safe Haskell | None |
Language | Haskell98 |
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.
- data BlockingQueue a
- type SizeLimit = Int
- data BlockingQueueStats = BlockingQueueStats {
- maxJobs :: Int
- activeJobs :: Int
- queuedJobs :: Int
- start :: forall a. Serializable a => Process (InitResult (BlockingQueue a)) -> Process ()
- pool :: forall a. Serializable a => SizeLimit -> Process (InitResult (BlockingQueue a))
- executeTask :: forall s a. (Addressable s, Serializable a) => s -> Closure (Process a) -> Process (Either ExitReason a)
- stats :: forall s. Addressable s => s -> Process (Maybe BlockingQueueStats)
Documentation
data BlockingQueue a Source
data BlockingQueueStats Source
BlockingQueueStats | |
|
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.