concurrent-batch-0.1.0.0: Concurrent batching queue based on STM with timeout.

Safe HaskellSafe
LanguageHaskell2010

Control.Concurrent.STM.Batch

Contents

Synopsis

Documentation

data Batch a Source #

Opaque batch with buffer and settings.

Batch Operations

newBatch Source #

Arguments

:: Int

Max items in a batch

-> Maybe TimeSpec

Batch timeout

-> ([a] -> STM ())

Handler for complete batch

-> IO (Batch a)

Batch with settings

Constructs a new batcher state. If a batch timeout is configured this operation will automatically spawn a timeout handler thread. The timeout handler will automatically be killed when the batcher is garbage collected.

writeBatch :: Batch a -> a -> IO () Source #

Add a single item to the batch. The batch is automatically flushed when full.

flushBatch :: Batch a -> STM () Source #

Fires the batchHandler for the current batch from the current thread. This function is automatically called for a timeout or when buffer is filled by a write operation.

Time Utilities

fromMilliSecs :: Integer -> TimeSpec Source #

Convenience function for timeout in milliseconds.

fromSecs :: Integer -> TimeSpec Source #

Convenience function for timeout in seconds.

fromMicroSecs :: Integer -> TimeSpec Source #

Highest resolution time supported by internal usage of threadDelay.

Re-exports

data TimeSpec #

TimeSpec structure

Constructors

TimeSpec 

Fields

Instances
Eq TimeSpec 
Instance details

Defined in System.Clock

Num TimeSpec 
Instance details

Defined in System.Clock

Ord TimeSpec 
Instance details

Defined in System.Clock

Read TimeSpec 
Instance details

Defined in System.Clock

Show TimeSpec 
Instance details

Defined in System.Clock

Generic TimeSpec 
Instance details

Defined in System.Clock

Associated Types

type Rep TimeSpec :: * -> * #

Methods

from :: TimeSpec -> Rep TimeSpec x #

to :: Rep TimeSpec x -> TimeSpec #

Storable TimeSpec 
Instance details

Defined in System.Clock

type Rep TimeSpec 
Instance details

Defined in System.Clock

type Rep TimeSpec = D1 (MetaData "TimeSpec" "System.Clock" "clock-0.7.2-ErKmPTjVISxJnEb9XKUAOs" False) (C1 (MetaCons "TimeSpec" PrefixI True) (S1 (MetaSel (Just "sec") SourceUnpack SourceStrict DecidedStrict) (Rec0 Int64) :*: S1 (MetaSel (Just "nsec") SourceUnpack SourceStrict DecidedStrict) (Rec0 Int64)))