git-annex/Utility/ThreadLock.hs
Joey Hess 1ff889e456
explict export lists
A small amount of dead code removed.

All of Utility/ done now.

This commit was sponsored by Brock Spratlen on Patreon.
2019-11-23 11:24:10 -04:00

23 lines
417 B
Haskell

{- locking between threads
-
- Copyright 2012 Joey Hess <id@joeyh.name>
-
- License: BSD-2-clause
-}
module Utility.ThreadLock (
Lock,
newLock,
withLock,
) where
import Control.Concurrent.MVar
type Lock = MVar ()
newLock :: IO Lock
newLock = newMVar ()
{- Runs an action with a lock held, so only one thread at a time can run it. -}
withLock :: Lock -> IO a -> IO a
withLock lock = withMVar lock . const