Copyright | (c) 2021 Xy Ren |
---|---|
License | BSD3 |
Maintainer | xy.r@outlook.com |
Stability | unstable |
Portability | non-portable (GHC only) |
Safe Haskell | None |
Language | Haskell2010 |
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
- data ThreadVar a
- newThreadVar :: a -> IO (ThreadVar a)
- getThreadVar :: ThreadVar a -> IO (IORef a)
Documentation
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.