Pup-Events-PQueue-1.0: A networked event handling framework for hooking into other programs.

Safe HaskellSafe-Infered

PupEventsPQueue

Description

Implements Priority Queues intended to be used with the STM module.

Synopsis

Documentation

makeQueuesSource

Arguments

:: Int

The number of priority levels

-> IO (PQueue a)

The PQueue

Returns an empty PQueue with the specified number of priority levels.

getThingSource

Arguments

:: PQueue a

The PQueue to search

-> STM (Maybe a)

Just the item or Nothing.

Recursively tries to read each priority level until it finds something. If it can't find any events it returns Nothing. Call using atomically $ getThing pqueue.

writeThingSource

Arguments

:: PQueue a

The PQueue to write to

-> Int

The priority level

-> a

The thing to write

-> STM () 

Writes the given something to the given PQueue at the specified priority level. It does some checking to make sure we have a valid priority level. Call using atomically $ writeThing pqueue priority thing.

type PQueue a = [TChan a]Source

A simple alias so we have pretty types.