Class: Dispatch::BackgroundObject
- Defined in:
- lib/carat-dev/detach/detach.rb
Overview
Used to create non-blocking remote method calls. Has an index of a work unit and a dispatch object to call on to do all the work.
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
Returns the value of attribute index.
Class Method Summary collapse
-
._load(d) ⇒ Object
I added when it choked needing this.
Instance Method Summary collapse
-
#initialize(dispatch) ⇒ BackgroundObject
constructor
A new instance of BackgroundObject.
-
#method_missing(msg_id, *a, &b) ⇒ Object
Passes all unknown method calls back to the original object by way of the dispatch.
-
#ready? ⇒ Boolean
(also: #done?)
Returns true if the real object is ready.
-
#stats ⇒ Object
Returns stats for the backgrouded call.
Constructor Details
#initialize(dispatch) ⇒ BackgroundObject
Returns a new instance of BackgroundObject.
166 167 168 169 |
# File 'lib/carat-dev/detach/detach.rb', line 166 def initialize(dispatch) @dispatch = dispatch @index = self.object_id() end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(msg_id, *a, &b) ⇒ Object
Passes all unknown method calls back to the original object by way of the dispatch.
177 178 179 180 181 182 |
# File 'lib/carat-dev/detach/detach.rb', line 177 def method_missing(msg_id, *a, &b) # puts "in #{Process.pid}, asking for #{msg_id} from a #{@dispatch.class}" obj = @dispatch._get_obj(@index) # puts "Ret is a #{obj.class}" obj.__send__(msg_id,*a,&b) end |
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
164 165 166 |
# File 'lib/carat-dev/detach/detach.rb', line 164 def index @index end |
Class Method Details
._load(d) ⇒ Object
I added when it choked needing this
197 198 |
# File 'lib/carat-dev/detach/detach.rb', line 197 def self._load(d) end |
Instance Method Details
#ready? ⇒ Boolean Also known as: done?
Returns true if the real object is ready.
185 186 187 188 |
# File 'lib/carat-dev/detach/detach.rb', line 185 def ready? # puts "Checking for readiness from #{Process.pid}" @dispatch._obj_ready?(@index) end |
#stats ⇒ Object
Returns stats for the backgrouded call.
192 193 194 |
# File 'lib/carat-dev/detach/detach.rb', line 192 def stats @dispatch._obj_stats(@index) end |