Stability | experimental |
---|---|
Maintainer | David Sorokin <david.sorokin@gmail.com> |
Safe Haskell | Safe-Inferred |
Tested with: GHC 7.6.3
The module introduces the event queue. An event handler is the Dynamics computation that has a single purpose to perform some side effect at the desired time. To pass in any message to the event, you can use a closure.
- data EventQueue
- newQueue :: Simulation EventQueue
- enqueue :: EventQueue -> Double -> Dynamics () -> Dynamics ()
- enqueueWithTimes :: EventQueue -> [Double] -> Dynamics () -> Dynamics ()
- enqueueWithIntegTimes :: EventQueue -> Dynamics () -> Dynamics ()
- enqueueWithStartTime :: EventQueue -> Dynamics () -> Dynamics ()
- enqueueWithStopTime :: EventQueue -> Dynamics () -> Dynamics ()
- enqueueWithCurrentTime :: EventQueue -> Dynamics () -> Dynamics ()
- runQueue :: EventQueue -> Dynamics ()
- runQueueSync :: EventQueue -> Dynamics ()
- runQueueBefore :: EventQueue -> Dynamics ()
- runQueueSyncBefore :: EventQueue -> Dynamics ()
- queueCount :: EventQueue -> Dynamics Int
Documentation
data EventQueue Source
The EventQueue
type represents the event queue.
newQueue :: Simulation EventQueueSource
Create a new event queue.
enqueue :: EventQueue -> Double -> Dynamics () -> Dynamics ()Source
Enqueue the event which must be actuated at the specified time.
enqueueWithTimes :: EventQueue -> [Double] -> Dynamics () -> Dynamics ()Source
Actuate the event handler in the specified time points.
enqueueWithIntegTimes :: EventQueue -> Dynamics () -> Dynamics ()Source
Actuate the event handler in the integration time points.
enqueueWithStartTime :: EventQueue -> Dynamics () -> Dynamics ()Source
Actuate the event handler in the start time.
enqueueWithStopTime :: EventQueue -> Dynamics () -> Dynamics ()Source
Actuate the event handler in the stop time.
enqueueWithCurrentTime :: EventQueue -> Dynamics () -> Dynamics ()Source
Actuate the event handler in the current time but through the event queue, which allows continuing the current tasks and then calling the handler after the tasks are finished. The simulation time will be the same.
runQueue :: EventQueue -> Dynamics ()Source
Run the event queue processing its events. There is no restiction on the time of the queue itself. It this time is greater than the current simulation time then nothing happens.
runQueueSync :: EventQueue -> Dynamics ()Source
Run the event queue synchronously, i.e. the current time cannot be less than the actual time of the queue itself.
You will rarely need to run the event queue explicitly, but if you do want then this function is probably that one you should use.
runQueueBefore :: EventQueue -> Dynamics ()Source
Run the event queue processing only those events which time is less than the current simulation time. There is no restiction on the time of the queue itself. It this time is greater than the current simulation time then nothing happens.
runQueueSyncBefore :: EventQueue -> Dynamics ()Source
Run the event queue synchronously processing only those events which time is less than the current simulation time. But the current time cannot be less than the actual time of the queue itself.
This function is usually called before a handler is subscribed
to the signal. Earlier runQueueSync
was called instead, which could
lead to the lost of the signal by the handler at time of direct
subscribing. Changed in version 0.6.1.
queueCount :: EventQueue -> Dynamics IntSource
Return the number of pending events that should be yet actuated.