In Files

  • monitor/lib/monitor.rb

Class/Module Index [+]

Quicksearch

MonitorMixin

Public Class Methods

extend_object(obj) click to toggle source
 
               # File monitor/lib/monitor.rb, line 153
def self.extend_object(obj)
  super(obj)
  obj.__send__(:mon_initialize)
end
            
new(...) click to toggle source

Use extend MonitorMixin or include MonitorMixin instead of this constructor. Have look at the examples above to understand how to use this module.

 
               # File monitor/lib/monitor.rb, line 223
def initialize(...)
  super
  mon_initialize
end
            

Public Instance Methods

mon_enter() click to toggle source

Enters exclusive section.

 
               # File monitor/lib/monitor.rb, line 170
def mon_enter
  @mon_data.enter
end
            
mon_exit() click to toggle source

Leaves exclusive section.

 
               # File monitor/lib/monitor.rb, line 177
def mon_exit
  mon_check_owner
  @mon_data.exit
end
            
mon_locked?() click to toggle source

Returns true if this monitor is locked by any thread

 
               # File monitor/lib/monitor.rb, line 185
def mon_locked?
  @mon_data.mon_locked?
end
            
mon_owned?() click to toggle source

Returns true if this monitor is locked by current thread.

 
               # File monitor/lib/monitor.rb, line 192
def mon_owned?
  @mon_data.mon_owned?
end
            
mon_synchronize(&b) click to toggle source

Enters exclusive section and executes the block. Leaves the exclusive section automatically when the block exits. See example under MonitorMixin.

 
               # File monitor/lib/monitor.rb, line 201
def mon_synchronize(&b)
  @mon_data.synchronize(&b)
end
            
Also aliased as: synchronize
mon_try_enter() click to toggle source

Attempts to enter exclusive section. Returns false if lock fails.

 
               # File monitor/lib/monitor.rb, line 161
def mon_try_enter
  @mon_data.try_enter
end
            
Also aliased as: try_mon_enter
new_cond() click to toggle source

Creates a new MonitorMixin::ConditionVariable associated with the Monitor object.

 
               # File monitor/lib/monitor.rb, line 210
def new_cond
  unless defined?(@mon_data)
    mon_initialize
    @mon_initialized_by_new_cond = true
  end
  return ConditionVariable.new(@mon_data)
end
            
synchronize(&b) click to toggle source
Alias for: mon_synchronize
try_mon_enter() click to toggle source

For backward compatibility

Alias for: mon_try_enter