Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Synopsis
- class EQueue eq where
- registerSemi :: (MonadIO m, Semigroup b) => eq a -> (b -> a) -> m (b -> IO (), IO ())
- registerQueued :: MonadIO m => eq a -> m (a -> IO (), IO ())
- class EQueueW eq where
- waitEQ :: MonadIO m => eq a -> WaitPolicy eq -> m [a]
- data AnyEQueue a where
- data ForceEdge a where
- data MappedEQueue eq b a where
- MEQ :: (a -> b) -> eq b -> MappedEQueue eq b a
- meqEQ :: MappedEQueue eq b a -> eq b
- data STMEQueue a
- data STMEQueueWait
- newSTMEQueue :: MonadIO m => m (STMEQueue a)
Documentation
class EQueue eq where Source #
An EQueue is a way of managing edge and level triggered events. The choice of EQueue implementation allows late binding of the policy by which the application processes events.
registerSemi :: (MonadIO m, Semigroup b) => eq a -> (b -> a) -> m (b -> IO (), IO ()) Source #
Registers a level triggered event. These are the events that accumulate a combined change or resulting state. Returns a function to enqueue updates and unregister this event.
registerQueued :: MonadIO m => eq a -> m (a -> IO (), IO ()) Source #
Registers an edge triggered event. Returns a function to enqueue updates and unregister this event.
Instances
class EQueueW eq where Source #
An EQueueW is the interface for waiting on events in a queue.
waitEQ :: MonadIO m => eq a -> WaitPolicy eq -> m [a] Source #
The dequeue operation, collecting some set of available events, depending on the particular policy the given EQueue impliments.
Instances
EQueueW STMEQueue Source # | |
Defined in Control.Concurrent.EQueue.STMEQueue type WaitPolicy STMEQueue :: Type Source # | |
EQueueW TQueueEQueue Source # | |
Defined in Control.Concurrent.EQueue.Simple type WaitPolicy TQueueEQueue :: Type Source # waitEQ :: MonadIO m => TQueueEQueue a -> WaitPolicy TQueueEQueue -> m [a] Source # | |
EQueueW TChanEQueue Source # | |
Defined in Control.Concurrent.EQueue.Simple type WaitPolicy TChanEQueue :: Type Source # waitEQ :: MonadIO m => TChanEQueue a -> WaitPolicy TChanEQueue -> m [a] Source # | |
EQueueW ChanEQueue Source # | |
Defined in Control.Concurrent.EQueue.Simple type WaitPolicy ChanEQueue :: Type Source # waitEQ :: MonadIO m => ChanEQueue a -> WaitPolicy ChanEQueue -> m [a] Source # |
data AnyEQueue a where Source #
Allows us to return an unknown instance of EQueue, getting around Haskells lack of existential qualification.
data ForceEdge a where Source #
A wrapper that translates level triggered events into events that observe the edges.
data MappedEQueue eq b a where Source #
A wrapper that allows us to pretend a queue of one type is of another.
MEQ :: (a -> b) -> eq b -> MappedEQueue eq b a |
Instances
Contravariant (MappedEQueue eq b) Source # | |
Defined in Control.Concurrent.EQueue contramap :: (a -> b0) -> MappedEQueue eq b b0 -> MappedEQueue eq b a # (>$) :: b0 -> MappedEQueue eq b b0 -> MappedEQueue eq b a # | |
EQueue eq => EQueue (MappedEQueue eq b) Source # | |
Defined in Control.Concurrent.EQueue registerSemi :: (MonadIO m, Semigroup b0) => MappedEQueue eq b a -> (b0 -> a) -> m (b0 -> IO (), IO ()) Source # registerQueued :: MonadIO m => MappedEQueue eq b a -> m (a -> IO (), IO ()) Source # |
meqEQ :: MappedEQueue eq b a -> eq b Source #
Retrieve the EQueue we're mapping to from the MappedEQueue.
A basic example implimentation of an EQueue using STM. This implimentation must look at every registered event source leading to inefficiency in systems with a very large number of sources. For most systems it should be a sufficient implimentation though.
Instances
EQueueW STMEQueue Source # | |
Defined in Control.Concurrent.EQueue.STMEQueue type WaitPolicy STMEQueue :: Type Source # | |
EQueue STMEQueue Source # | |
type WaitPolicy STMEQueue Source # | |
Defined in Control.Concurrent.EQueue.STMEQueue |
data STMEQueueWait Source #
The policy for waiting on an STMEQueue.
ReturnImmediate | Immediately return, even if no events are available. |
RequireEvent | Wait for at least one event to be available before returning. |
Instances
Eq STMEQueueWait Source # | |
Defined in Control.Concurrent.EQueue.STMEQueue (==) :: STMEQueueWait -> STMEQueueWait -> Bool # (/=) :: STMEQueueWait -> STMEQueueWait -> Bool # |
newSTMEQueue :: MonadIO m => m (STMEQueue a) Source #
Create a new STMEQueue which initally has no event sources registered.