Stability | experimental |
---|---|
Maintainer | David Sorokin <david.sorokin@gmail.com> |
Safe Haskell | Safe-Inferred |
Tested with: GHC 7.6.3
This module defines a limited resource which can be acquired and
then released by the discontinuous process Process
.
- data Resource s q
- newResource :: QueueStrategy s q => s -> Int -> Simulation (Resource s q)
- newResourceWithCount :: QueueStrategy s q => s -> Int -> Int -> Simulation (Resource s q)
- resourceMaxCount :: Resource s q -> Int
- resourceCount :: Resource s q -> Event Int
- requestResource :: EnqueueStrategy s q => Resource s q -> Process ()
- requestResourceWithPriority :: PriorityQueueStrategy s q => Resource s q -> Double -> Process ()
- requestResourceWithDynamicPriority :: DynamicPriorityQueueStrategy s q => Resource s q -> Event Double -> Process ()
- tryRequestResourceWithinEvent :: Resource s q -> Event Bool
- releaseResource :: DequeueStrategy s q => Resource s q -> Process ()
- releaseResourceWithinEvent :: DequeueStrategy s q => Resource s q -> Event ()
- usingResource :: EnqueueStrategy s q => Resource s q -> Process a -> Process a
- usingResourceWithPriority :: PriorityQueueStrategy s q => Resource s q -> Double -> Process a -> Process a
- usingResourceWithDynamicPriority :: DynamicPriorityQueueStrategy s q => Resource s q -> Event Double -> Process a -> Process a
Documentation
:: QueueStrategy s q | |
=> s | the strategy for managing the queuing requests |
-> Int | the maximum count of the resource |
-> Simulation (Resource s q) |
Create a new resource with the specified queue strategy and maximum count.
:: QueueStrategy s q | |
=> s | the strategy for managing the queuing requests |
-> Int | the maximum count of the resource |
-> Int | the initial count of the resource |
-> Simulation (Resource s q) |
Create a new resource with the specified queue strategy, maximum and initial count.
resourceMaxCount :: Resource s q -> IntSource
Return the maximum count of the resource.
resourceCount :: Resource s q -> Event IntSource
Return the current count of the resource.
:: EnqueueStrategy s q | |
=> Resource s q | the requested resource |
-> Process () |
Request for the resource decreasing its count in case of success, otherwise suspending the discontinuous process until some other process releases the resource.
requestResourceWithPrioritySource
:: PriorityQueueStrategy s q | |
=> Resource s q | the requested resource |
-> Double | the priority |
-> Process () |
Request with the priority for the resource decreasing its count in case of success, otherwise suspending the discontinuous process until some other process releases the resource.
requestResourceWithDynamicPrioritySource
:: DynamicPriorityQueueStrategy s q | |
=> Resource s q | the requested resource |
-> Event Double | the dynamic priority |
-> Process () |
Request with the dynamic priority for the resource decreasing its count in case of success, otherwise suspending the discontinuous process until some other process releases the resource.
:: DequeueStrategy s q | |
=> Resource s q | the resource to release |
-> Process () |
Release the resource increasing its count and resuming one of the previously suspended processes as possible.
releaseResourceWithinEventSource
:: DequeueStrategy s q | |
=> Resource s q | the resource to release |
-> Event () |
Release the resource increasing its count and resuming one of the previously suspended processes as possible.
:: EnqueueStrategy s q | |
=> Resource s q | the resource we are going to request for and then release in the end |
-> Process a | the action we are going to apply having the resource |
-> Process a | the result of the action |
Acquire the resource, perform some action and safely release the resource
in the end, even if the IOException
was raised within the action.
The process identifier must be created with support of exception
handling, i.e. with help of function newProcessIdWithCatch
. Unfortunately,
such processes are slower than those that are created with help of
other function newProcessId
.
usingResourceWithPrioritySource
:: PriorityQueueStrategy s q | |
=> Resource s q | the resource we are going to request for and then release in the end |
-> Double | the priority |
-> Process a | the action we are going to apply having the resource |
-> Process a | the result of the action |
Acquire the resource with the specified priority, perform some action and
safely release the resource in the end, even if the IOException
was raised
within the action. The process identifier must be created with support of exception
handling, i.e. with help of function newProcessIdWithCatch
. Unfortunately,
such processes are slower than those that are created with help of
other function newProcessId
.
usingResourceWithDynamicPrioritySource
:: DynamicPriorityQueueStrategy s q | |
=> Resource s q | the resource we are going to request for and then release in the end |
-> Event Double | the dynamic priority |
-> Process a | the action we are going to apply having the resource |
-> Process a | the result of the action |
Acquire the resource with the dynamic priority, perform some action and
safely release the resource in the end, even if the IOException
was raised
within the action. The process identifier must be created with support of exception
handling, i.e. with help of function newProcessIdWithCatch
. Unfortunately,
such processes are slower than those that are created with help of
other function newProcessId
.