A monad supporting atomic memory transactions.
A modular composable concurrency abstraction.
Turn I/O operations into STM transactions on channels.
Additional types of channels for STM.
Provides two simple conduit wrappers around STM channels - a source and a sink.
This library provides an Software Transactional Memory (STM) monad with commit and retry IO hooks. A retry-action is run (at least once) if the transaction retries, while commit-actions are executed iff the transaction commits. The AdvSTM monad also gives some atomicity guarantees for commit-actions:
* When a TVar is modified in a transaction and this transaction commits, the update remains invisible to other threads until the corresponding onCommit action is run.
* If the onCommit action throws an exception, the original values of the modified TVars are restored.
Note: The package can be used as a drop-in replacement for Control.Concurrent.STM. This library was inspired by the AdvSTM monad on the Haskell Wiki (see http://haskell.org/haskellwiki/?title=New_monads/MonadAdvSTM).
Feedback is welcome!
Doubly linked lists are often used in imperative languages to maintain a collection of objects such that an object can remove itself easily. The same idea applies here. Thanks to STM, these lists can be shared among threads with little effort.
Suppose you have a thread listening for events. You want to dispatch events to any thread that opts in. You could write a function that installs an event handler, performs an action, and removes the handler:
> withEventHandler list handler action =
> bracket (atomically $ LinkedList.append handler list)
> (atomically . LinkedList.delete)
> (\_ -> action)
Then, you could have your listener thread dispatch events using a function like this:
> dispatchEvent list event = do
> handlers <- atomically $ LinkedList.toList list
> forM_ handlers $ \handler -> handler event
Transactional MVars, Vars and Channels with distinguished input and output side. When threads communicate via a TMVar, a TVar or a TChan there are often clearly defined roles, which thread is the sender and which one is receiver. We provide wrappers around the standard concurrency communication channels that make the distinction clear and type safe.
For example, if a function has a parameter of type TChan.In then it is sure that it will only write to that channel. Additionally if the compiler warns about an unused TChan.Out that was created by TChan.new then you know that the receiver part of your communication is missing.
See also package concurrent-split for non-transactional communication. This package follows the same idea as chan-split but is strictly Haskell 98.
This module provides functions that can replace calls to atomically and count how often the transaction was retried until it succeeded. It can emit warnings when transaction are retried more often than a given threshold, and provides global statistics across all transaction.
As an additional feature, if the transaction was named, transaction-related exceptions such as BlockedIndefinitelyOnSTM are replaced by variants that indicate which transaction caused the exception.
0.2.0.0: (2011-10-10) : Added warnInSTMFunction to TrackSTMConf. : Bugfix with the global retry count warning. 0.1.0.0: (2011-10-09) : Initial Release
This package provides a mutable, singly-linked list type for use in STM. It is based on the design of Control.Concurrent.TChan, and can be used to implement a wide variety of channel types.
Control communication among retrying transactions
A monad transformer version of the ST monad Warning! This monad transformer should not be used with monads that can contain multiple answers, like the list monad. The reason is that the will be duplicated across the different answers and this cause Bad Things to happen (such as loss of referential transparency). Safe monads include the monads State, Reader, Writer, Maybe and combinations of their corresponding monad transformers.
Exception handling within STM actions.
ChristmasTree (Changing Haskell's Read Implementation Such That by Mainpulating ASTs it Reads Expressions Efficiently) is an alternative approach of read that composes grammars instead of parsers. It reads data in linear time, while the function read has an exponential behavior in some cases of data types with infix operators.
The DSTM package consists of the DSTM library, a name server application, and three sample distributed programs using the library. DSTM is a framework enabling the use of the STM interface, known from concurrent programming, to be used for distributed Haskell applications as well. Provided are a simple Dining Philosophers, a Chat, and a soft real-time Bomberman game application.
Distributed communication is transparent to the application programmer. The application designer uses a very simple nameserver mechanism to set up the system. The DSTM library includes the management of unavailable process nodes and provides the application with abstract error information thus facilitating the implementation of robust distributed application programs.
For usage please look into the included file: DSTMManual.pdf, also available at http://www.informatik.uni-kiel.de/prog/mitarbeiter/frank-kupke/.
Changes from last version:
* documentation available online
* fixed typos in Chat example
* set debug flags to no debug output
Distributed annotation for PostScript and PDF documents.
Enumerators and iteratees which read from/write to STM channels. This allows for processes with dedicated IO threads.
Show more results