equeue-0: Application level triggered, and edge triggered event multiqueues.

Safe HaskellSafe
LanguageHaskell2010

Control.Concurrent.EQueue

Synopsis

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.

Methods

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
EQueue STMEQueue Source # 
Instance details

Defined in Control.Concurrent.EQueue.STMEQueue

Methods

registerSemi :: (MonadIO m, Semigroup b) => STMEQueue a -> (b -> a) -> m (b -> IO (), IO ()) Source #

registerQueued :: MonadIO m => STMEQueue a -> m (a -> IO (), IO ()) Source #

EQueue ForceEdge Source # 
Instance details

Defined in Control.Concurrent.EQueue

Methods

registerSemi :: (MonadIO m, Semigroup b) => ForceEdge a -> (b -> a) -> m (b -> IO (), IO ()) Source #

registerQueued :: MonadIO m => ForceEdge a -> m (a -> IO (), IO ()) Source #

EQueue AnyEQueue Source # 
Instance details

Defined in Control.Concurrent.EQueue

Methods

registerSemi :: (MonadIO m, Semigroup b) => AnyEQueue a -> (b -> a) -> m (b -> IO (), IO ()) Source #

registerQueued :: MonadIO m => AnyEQueue a -> m (a -> IO (), IO ()) Source #

EQueue IOEQueue Source # 
Instance details

Defined in Control.Concurrent.EQueue.Simple

Methods

registerSemi :: (MonadIO m, Semigroup b) => IOEQueue a -> (b -> a) -> m (b -> IO (), IO ()) Source #

registerQueued :: MonadIO m => IOEQueue a -> m (a -> IO (), IO ()) Source #

EQueue TQueueEQueue Source #

Can not unregister events

Instance details

Defined in Control.Concurrent.EQueue.Simple

Methods

registerSemi :: (MonadIO m, Semigroup b) => TQueueEQueue a -> (b -> a) -> m (b -> IO (), IO ()) Source #

registerQueued :: MonadIO m => TQueueEQueue a -> m (a -> IO (), IO ()) Source #

EQueue TChanEQueue Source #

Can not unregister events

Instance details

Defined in Control.Concurrent.EQueue.Simple

Methods

registerSemi :: (MonadIO m, Semigroup b) => TChanEQueue a -> (b -> a) -> m (b -> IO (), IO ()) Source #

registerQueued :: MonadIO m => TChanEQueue a -> m (a -> IO (), IO ()) Source #

EQueue ChanEQueue Source #

Can not unregister events

Instance details

Defined in Control.Concurrent.EQueue.Simple

Methods

registerSemi :: (MonadIO m, Semigroup b) => ChanEQueue a -> (b -> a) -> m (b -> IO (), IO ()) Source #

registerQueued :: MonadIO m => ChanEQueue a -> m (a -> IO (), IO ()) Source #

EQueue eq => EQueue (MappedEQueue eq b) Source # 
Instance details

Defined in Control.Concurrent.EQueue

Methods

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 #

class EQueueW eq where Source #

An EQueueW is the interface for waiting on events in a queue.

Methods

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 # 
Instance details

Defined in Control.Concurrent.EQueue.STMEQueue

Associated Types

type WaitPolicy STMEQueue :: Type Source #

Methods

waitEQ :: MonadIO m => STMEQueue a -> WaitPolicy STMEQueue -> m [a] Source #

EQueueW TQueueEQueue Source # 
Instance details

Defined in Control.Concurrent.EQueue.Simple

Associated Types

type WaitPolicy TQueueEQueue :: Type Source #

EQueueW TChanEQueue Source # 
Instance details

Defined in Control.Concurrent.EQueue.Simple

Associated Types

type WaitPolicy TChanEQueue :: Type Source #

Methods

waitEQ :: MonadIO m => TChanEQueue a -> WaitPolicy TChanEQueue -> m [a] Source #

EQueueW ChanEQueue Source # 
Instance details

Defined in Control.Concurrent.EQueue.Simple

Associated Types

type WaitPolicy ChanEQueue :: Type Source #

Methods

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.

Constructors

AEQ :: EQueue eq => eq a -> AnyEQueue a 
Instances
EQueue AnyEQueue Source # 
Instance details

Defined in Control.Concurrent.EQueue

Methods

registerSemi :: (MonadIO m, Semigroup b) => AnyEQueue a -> (b -> a) -> m (b -> IO (), IO ()) Source #

registerQueued :: MonadIO m => AnyEQueue a -> m (a -> IO (), IO ()) Source #

data ForceEdge a where Source #

A wrapper that translates level triggered events into events that observe the edges.

Constructors

EEQ :: EQueue eq => eq a -> ForceEdge a 
Instances
EQueue ForceEdge Source # 
Instance details

Defined in Control.Concurrent.EQueue

Methods

registerSemi :: (MonadIO m, Semigroup b) => ForceEdge a -> (b -> a) -> m (b -> IO (), IO ()) Source #

registerQueued :: MonadIO m => ForceEdge a -> m (a -> IO (), IO ()) Source #

data MappedEQueue eq b a where Source #

A wrapper that allows us to pretend a queue of one type is of another.

Constructors

MEQ :: (a -> b) -> eq b -> MappedEQueue eq b a 
Instances
Contravariant (MappedEQueue eq b) Source # 
Instance details

Defined in Control.Concurrent.EQueue

Methods

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 # 
Instance details

Defined in Control.Concurrent.EQueue

Methods

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.

data STMEQueue a Source #

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 # 
Instance details

Defined in Control.Concurrent.EQueue.STMEQueue

Associated Types

type WaitPolicy STMEQueue :: Type Source #

Methods

waitEQ :: MonadIO m => STMEQueue a -> WaitPolicy STMEQueue -> m [a] Source #

EQueue STMEQueue Source # 
Instance details

Defined in Control.Concurrent.EQueue.STMEQueue

Methods

registerSemi :: (MonadIO m, Semigroup b) => STMEQueue a -> (b -> a) -> m (b -> IO (), IO ()) Source #

registerQueued :: MonadIO m => STMEQueue a -> m (a -> IO (), IO ()) Source #

type WaitPolicy STMEQueue Source # 
Instance details

Defined in Control.Concurrent.EQueue.STMEQueue

data STMEQueueWait Source #

The policy for waiting on an STMEQueue.

Constructors

ReturnImmediate

Immediately return, even if no events are available.

RequireEvent

Wait for at least one event to be available before returning.

newSTMEQueue :: MonadIO m => m (STMEQueue a) Source #

Create a new STMEQueue which initally has no event sources registered.