File: .lake/packages/lean4/src/lean/Init/System/Mutex.lean

full_name: _private.«.lake».packages.lean4.src.lean.Init.System.Mutex.0.IO.BaseMutexImpl
code: private opaque BaseMutexImpl : NonemptyType.{0}
goal: NonemptyType

full_name: IO.BaseMutex
code: /--
Mutual exclusion primitive (a lock).

If you want to guard shared state, use `Mutex α` instead.
-/
def BaseMutex : Type 
goal: Type

full_name: IO.instNonemptyBaseMutex
code: instance : Nonempty BaseMutex 
goal: Nonempty IO.BaseMutex

full_name: IO.BaseMutex.new
code: /-- Creates a new `BaseMutex`. -/
@[extern "lean_io_basemutex_new"]
opaque BaseMutex.new : BaseIO BaseMutex
goal: BaseIO IO.BaseMutex

full_name: IO.BaseMutex.lock
code: /--
Locks a `BaseMutex`.  Waits until no other thread has locked the mutex.

The current thread must not have already locked the mutex.
Reentrant locking is undefined behavior (inherited from the C++ implementation).
-/
@[extern "lean_io_basemutex_lock"]
opaque BaseMutex.lock (mutex : @& BaseMutex) : BaseIO Unit
goal: BaseIO Unit

full_name: IO.BaseMutex.unlock
code: /--
Unlocks a `BaseMutex`.

The current thread must have already locked the mutex.
Unlocking an unlocked mutex is undefined behavior (inherited from the C++ implementation).
-/
@[extern "lean_io_basemutex_unlock"]
opaque BaseMutex.unlock (mutex : @& BaseMutex) : BaseIO Unit
goal: BaseIO Unit

full_name: _private.«.lake».packages.lean4.src.lean.Init.System.Mutex.0.IO.CondvarImpl
code: private opaque CondvarImpl : NonemptyType.{0}
goal: NonemptyType

full_name: IO.Condvar
code: /-- Condition variable. -/
def Condvar : Type 
goal: Type

full_name: IO.instNonemptyCondvar
code: instance : Nonempty Condvar 
goal: Nonempty IO.Condvar

full_name: IO.Condvar.new
code: /-- Creates a new condition variable. -/
@[extern "lean_io_condvar_new"]
opaque Condvar.new : BaseIO Condvar
goal: BaseIO IO.Condvar

full_name: IO.Condvar.wait
code: /-- Waits until another thread calls `notifyOne` or `notifyAll`. -/
@[extern "lean_io_condvar_wait"]
opaque Condvar.wait (condvar : @& Condvar) (mutex : @& BaseMutex) : BaseIO Unit
goal: BaseIO Unit

full_name: IO.Condvar.notifyOne
code: /-- Wakes up a single other thread executing `wait`. -/
@[extern "lean_io_condvar_notify_one"]
opaque Condvar.notifyOne (condvar : @& Condvar) : BaseIO Unit
goal: BaseIO Unit

full_name: IO.Condvar.notifyAll
code: /-- Wakes up all other threads executing `wait`. -/
@[extern "lean_io_condvar_notify_all"]
opaque Condvar.notifyAll (condvar : @& Condvar) : BaseIO Unit
goal: BaseIO Unit

full_name: IO.Condvar.waitUntil
code: /-- Waits on the condition variable until the predicate is true. -/
def Condvar.waitUntil [Monad m] [MonadLift BaseIO m]
    (condvar : Condvar) (mutex : BaseMutex) (pred : m Bool) : m Unit 
goal: m Unit

full_name: _private.«.lake».packages.lean4.src.lean.Init.System.Mutex.0.IO.Mutex.mk
code: /--
Mutual exclusion primitive (lock) guarding shared state of type `α`.

The type `Mutex α` is similar to `IO.Ref α`,
except that concurrent accesses are guarded by a mutex
instead of atomic pointer operations and busy-waiting.
-/
structure Mutex (α : Type) where private mk ::
  private ref : IO.Ref α
  mutex : BaseMutex
  deriving Nonempty
goal: IO.Mutex α

full_name: IO.Mutex.mutex
code: /--
Mutual exclusion primitive (lock) guarding shared state of type `α`.

The type `Mutex α` is similar to `IO.Ref α`,
except that concurrent accesses are guarded by a mutex
instead of atomic pointer operations and busy-waiting.
-/
structure Mutex (α : Type) where private mk ::
  private ref : IO.Ref α
  mutex : BaseMutex
  deriving Nonempty
goal: IO.BaseMutex

full_name: IO.instNonemptyMutex
code: /--
Mutual exclusion primitive (lock) guarding shared state of type `α`.

The type `Mutex α` is similar to `IO.Ref α`,
except that concurrent accesses are guarded by a mutex
instead of atomic pointer operations and busy-waiting.
-/
structure Mutex (α : Type) where private mk ::
  private ref : IO.Ref α
  mutex : BaseMutex
  deriving Nonempty
goal: ∀ {α : Type} [inst : Nonempty α], Nonempty (IO.Mutex α)

full_name: IO.Mutex
code: /--
Mutual exclusion primitive (lock) guarding shared state of type `α`.

The type `Mutex α` is similar to `IO.Ref α`,
except that concurrent accesses are guarded by a mutex
instead of atomic pointer operations and busy-waiting.
-/
structure Mutex (α : Type) where private mk ::
  private ref : IO.Ref α
  mutex : BaseMutex
  deriving Nonempty
goal: Type

full_name: _private.«.lake».packages.lean4.src.lean.Init.System.Mutex.0.IO.Mutex.ref
code: /--
Mutual exclusion primitive (lock) guarding shared state of type `α`.

The type `Mutex α` is similar to `IO.Ref α`,
except that concurrent accesses are guarded by a mutex
instead of atomic pointer operations and busy-waiting.
-/
structure Mutex (α : Type) where private mk ::
  private ref : IO.Ref α
  mutex : BaseMutex
  deriving Nonempty
goal: IO.Ref α

full_name: IO.instCoeOutMutexBaseMutex
code: instance : CoeOut (Mutex α) BaseMutex 
goal: CoeOut (IO.Mutex α) IO.BaseMutex

full_name: IO.Mutex.new
code: /-- Creates a new mutex. -/
def Mutex.new (a : α) : BaseIO (Mutex α) 
goal: BaseIO (IO.Mutex α)

full_name: IO.AtomicT
code: /--
`AtomicT α m` is the monad that can be atomically executed inside a `Mutex α`,
with outside monad `m`.
The action has access to the state `α` of the mutex (via `get` and `set`).
-/
abbrev AtomicT 
goal: Type

full_name: IO.Mutex.atomically
code: /-- `mutex.atomically k` runs `k` with access to the mutex's state while locking the mutex. -/
def Mutex.atomically [Monad m] [MonadLiftT BaseIO m] [MonadFinally m]
    (mutex : Mutex α) (k : AtomicT α m β) : m β 
goal: m β

full_name: IO.Mutex.atomicallyOnce
code: /--
`mutex.atomicallyOnce condvar pred k` runs `k`,
waiting on `condvar` until `pred` returns true.
Both `k` and `pred` have access to the mutex's state.
-/
def Mutex.atomicallyOnce [Monad m] [MonadLiftT BaseIO m] [MonadFinally m]
    (mutex : Mutex α) (condvar : Condvar)
    (pred : AtomicT α m Bool) (k : AtomicT α m β) : m β 
goal: m β