cleff-0.3.4.0: Fast and concise extensible effects
Copyright(c) 2021 Xy Ren
LicenseBSD3
Maintainerxy.r@outlook.com
Stabilityunstable
Portabilitynon-portable (GHC only)
Safe HaskellNone
LanguageHaskell2010

Data.ThreadVar

Description

This module contains a contention-free thread-local variable datatype.

This is an internal module and its API may change even between minor versions. Therefore you should be extra careful if you're to depend on this module.

Synopsis

Documentation

data ThreadVar a Source #

A thread-local variable. It is designed so that any operation originating from existing threads produce no contention; thread contention only occurs when multiple new threads attempt to first-time access the variable at the same time.

newThreadVar :: a -> IO (ThreadVar a) Source #

Create a thread variable with a same initial value for each thread.

getThreadVar :: ThreadVar a -> IO (IORef a) Source #

Get the variable local to this thread, in the form of an IORef. It is guaranteed that the returned IORef will not be read or mutated by other threads inadvertently.