123456789_123456789_123456789_123456789_123456789_

Class: Monitor

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
Inherits: Object
Defined in: lib/monitor.rb

Overview

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

Constant Summary

::MonitorMixin - Included

EXCEPTION_IMMEDIATE, EXCEPTION_NEVER

Instance Attribute Summary

::MonitorMixin - Included

#mon_locked?

Returns true if this monitor is locked by any thread.

#mon_owned?

Returns true if this monitor is locked by current thread.

Instance Method Summary

::MonitorMixin - Included

#mon_enter

Enters exclusive section.

#mon_exit

Leaves exclusive section.

#mon_synchronize

Enters exclusive section and executes the block.

#mon_try_enter

Attempts to enter exclusive section.

#new_cond

Creates a new ::MonitorMixin::ConditionVariable associated with the receiver.

#synchronize
#try_mon_enter
#initialize

Use extend MonitorMixin or include MonitorMixin instead of this constructor.

#mon_check_owner, #mon_enter_for_cond, #mon_exit_for_cond,
#mon_initialize

Initializes the ::MonitorMixin after being included in a class or when an object has been extended with the ::MonitorMixin.

Instance Method Details

#enter

[ GitHub ]

  
# File 'lib/monitor.rb', line 300

alias enter mon_enter

#exit

[ GitHub ]

  
# File 'lib/monitor.rb', line 301

alias exit mon_exit

#try_enter

[ GitHub ]

  
# File 'lib/monitor.rb', line 299

alias try_enter try_mon_enter