Class: FutureResource
- Inherits:
-
Object
show all
- Defined in:
- lib/adhearsion/foundation/future_resource.rb
Defined Under Namespace
Classes: ResourceAlreadySetException
Instance Method Summary
collapse
Constructor Details
Returns a new instance of FutureResource.
5
6
7
8
|
# File 'lib/adhearsion/foundation/future_resource.rb', line 5
def initialize
@resource_lock = Monitor.new
@resource_value_blocker = @resource_lock.new_cond
end
|
Instance Method Details
14
15
16
17
18
19
|
# File 'lib/adhearsion/foundation/future_resource.rb', line 14
def resource
@resource_lock.synchronize do
@resource_value_blocker.wait unless defined? @resource
@resource
end
end
|
#resource=(resource) ⇒ Object
21
22
23
24
25
26
27
28
|
# File 'lib/adhearsion/foundation/future_resource.rb', line 21
def resource=(resource)
@resource_lock.synchronize do
raise ResourceAlreadySetException if defined? @resource
@resource = resource
@resource_value_blocker.broadcast
@resource_value_blocker = nil end
end
|
#set_yet? ⇒ Boolean
10
11
12
|
# File 'lib/adhearsion/foundation/future_resource.rb', line 10
def set_yet?
@resource_lock.synchronize { defined? @resource }
end
|