Holumbus-Distribution-0.1.1: intra- and inter-program communication

Portabilityportable
Stabilityexperimental
MaintainerStefan Schmidt (stefanschmidt@web.de)

Holumbus.Common.Threading

Description

Version : 0.1

Operations to start and stop threads which will not be killed when a regular exception occurs. In this case, the thread will continue working. Such a thread can only be killed by the stop-method. This whole thing is a wrapper around the normal lightweight thread functions.

The created threads execute a function in an infinite loop. This is the normal usecase for message dispatcher threads.

Synopsis

Documentation

type Thread = MVar ThreadDataSource

The thread datatype

newThread :: IO ThreadSource

Creates a new thread object. The thread will not be running.

setThreadDelay :: Int -> Thread -> IO ()Source

Sets the delay between two loop cycles. Default value: no delay.

setThreadAction :: IO () -> Thread -> IO ()Source

Sets the action function, which will be executed in each cycle

setThreadErrorHandler :: IO () -> Thread -> IO ()Source

Sets the error handler. It is activated, when the action function will raise an exception.

startThread :: Thread -> IO ()Source

Starts the thread.

stopThread :: Thread -> IO ()Source

Stops the thread. If the thread itself wants to stop from within the action function, the current cycle will be executed till the end. So statements after this function will still be executed.