Class: SynchronizedDelegator
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- SynchronizedDelegator
show all
- Defined in:
- lib/thread_safe/synchronized_delegator.rb
Instance Method Summary
(collapse)
Constructor Details
Returns a new instance of SynchronizedDelegator
28
29
30
31
|
# File 'lib/thread_safe/synchronized_delegator.rb', line 28
def initialize(obj)
__setobj__(obj)
@monitor = Monitor.new
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
- (Object) method_missing(method, *args, &block)
33
34
35
36
37
38
39
40
41
|
# File 'lib/thread_safe/synchronized_delegator.rb', line 33
def method_missing(method, *args, &block)
monitor = @monitor
begin
monitor.enter
super
ensure
monitor.exit
end
end
|
Instance Method Details
- (Object) setup
19
20
21
22
|
# File 'lib/thread_safe/synchronized_delegator.rb', line 19
def setup
@old_abort = Thread.abort_on_exception
Thread.abort_on_exception = true
end
|
- (Object) teardown
24
25
26
|
# File 'lib/thread_safe/synchronized_delegator.rb', line 24
def teardown
Thread.abort_on_exception = @old_abort
end
|