Class: VCAP::Concurrency::Proxy

Inherits:
Object
  • Object
show all
Defined in:
lib/vcap/concurrency/proxy.rb

Overview

A coarse grained thread-safe proxy object

Instance Method Summary collapse

Constructor Details

#initialize(orig) ⇒ Proxy

Returns a new instance of Proxy.



10
11
12
13
# File 'lib/vcap/concurrency/proxy.rb', line 10

def initialize(orig)
  @orig = orig
  @lock = Mutex.new
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &blk) ⇒ Object



15
16
17
# File 'lib/vcap/concurrency/proxy.rb', line 15

def method_missing(meth, *args, &blk)
  @lock.synchronize { @orig.send(meth, *args, &blk) }
end