aivika-0.3: A multi-paradigm simulation library

Stabilityexperimental
MaintainerDavid Sorokin <david.sorokin@gmail.com>
Safe HaskellSafe-Infered

Simulation.Aivika.Dynamics.Resource

Description

Tested with: GHC 7.0.3

This module defines a limited resource which can be acquired and then released by the discontinuous process Process.

Synopsis

Documentation

data Resource Source

Represents a limited resource.

Instances

newResource :: EventQueue -> Int -> Simulation ResourceSource

Create a new resource with the specified initial count.

resourceQueue :: Resource -> EventQueueSource

Return the bound event queue.

resourceInitCount :: Resource -> IntSource

Return the initial count of the resource.

resourceCount :: Resource -> Dynamics IntSource

Return the current count of the resource.

requestResource :: Resource -> Process ()Source

Request for the resource decreasing its count in case of success, otherwise suspending the discontinuous process until some other process releases the resource.

releaseResource :: Resource -> Process ()Source

Release the resource increasing its count and resuming one of the previously suspended processes as possible.