class Monitor
Use the Monitor class when you want to have a lock object for blocks with mutual exclusion.
require 'monitor' lock = Monitor.new lock.synchronize do # exclusive access end
Public Instance Methods
() → nil
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/monitor/0/monitor.rbs, line 19
def enter: () -> nil
Enters exclusive section.
Also aliased as: mon_enter
() → nil
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/monitor/0/monitor.rbs, line 27
def exit: () -> nil
Leaves exclusive section.
Also aliased as: mon_exit
() → nil
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/monitor/0/monitor.rbs, line 34
def mon_check_owner: () -> nil
() → bool
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/monitor/0/monitor.rbs, line 55
def mon_locked?: () -> bool
() → bool
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/monitor/0/monitor.rbs, line 62
def mon_owned?: () -> bool
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/monitor/0/monitor.rbs, line 85
def new_cond: () -> ::MonitorMixin::ConditionVariable
Creates a new MonitorMixin::ConditionVariable associated with the Monitor object.
[T] () { () → T } → T
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/monitor/0/monitor.rbs, line 94
def synchronize: [T] () { () -> T } -> T
Enters exclusive section and executes the block. Leaves the exclusive section automatically when the block exits. See example under MonitorMixin.
Also aliased as: mon_synchronize
() → bool
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/monitor/0/monitor.rbs, line 102
def try_enter: () -> bool
Attempts to enter exclusive section. Returns false if lock fails.
Also aliased as: mon_try_enter, try_mon_enter
(::MonitorMixin::ConditionVariable, Numeric? timeout) → untyped
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/monitor/0/monitor.rbs, line 114
def wait_for_cond: (::MonitorMixin::ConditionVariable, Numeric? timeout) -> untyped