Module: Zoidberg::Shell::InstanceMethods
- Defined in:
- lib/zoidberg/shell.rb
Instance Method Summary collapse
-
#_zoidberg_proxy(oxy = nil) ⇒ NilClass, Zoidberg::Proxy
(also: #current_self, #current_actor)
Provide access to the proxy instance from the real instance.
-
#_zoidberg_signal_interface ⇒ Object
Initialize the signal instance if not.
-
#abort(e) ⇒ Object
Customized method for raising exceptions that have been properly handled (preventing termination).
-
#after(interval) { ... } ⇒ Timer
Register an action to run after interval.
- #alive? ⇒ TrueClass, FalseClass
-
#broadcast(name, arg = nil) ⇒ TrueClass, FalseClass
Broadcast a signal to all waiters.
-
#every(interval) { ... } ⇒ Timer
Register a recurring action.
-
#link(inst) ⇒ TrueClass
Link given shelled instance to current shelled instance to handle any exceptions raised from async actions.
-
#signal(name, arg = nil) ⇒ TrueClass, FalseClass
Send a signal to single waiter.
- #timer ⇒ Timer
-
#wait_for(name) ⇒ Object
(also: #wait)
Wait for a given signal.
Instance Method Details
#_zoidberg_proxy(oxy = nil) ⇒ NilClass, Zoidberg::Proxy Also known as: current_self, current_actor
Provide access to the proxy instance from the real instance
324 325 326 327 328 329 330 331 332 333 |
# File 'lib/zoidberg/shell.rb', line 324 def _zoidberg_proxy(oxy=nil) if(oxy) @_zoidberg_proxy = oxy end if(@_zoidberg_proxy) @_zoidberg_proxy else Lazy.new(self.class){ @_zoidberg_proxy } end end |
#_zoidberg_signal_interface ⇒ Object
Initialize the signal instance if not
262 263 264 |
# File 'lib/zoidberg/shell.rb', line 262 def _zoidberg_signal_interface _zoidberg_proxy._zoidberg_signal_interface end |
#abort(e) ⇒ Object
Customized method for raising exceptions that have been properly handled (preventing termination)
352 353 354 355 356 357 358 359 360 |
# File 'lib/zoidberg/shell.rb', line 352 def abort(e) unless(e.is_a?(::Exception)) $stdout.puts "E: #{e.class} - #{e.ancestors}" e = StandardError.new(e) end new_e = ::Zoidberg::AbortException.new new_e.original_exception = e ::Kernel.raise new_e end |
#after(interval) { ... } ⇒ Timer
Register an action to run after interval
285 286 287 |
# File 'lib/zoidberg/shell.rb', line 285 def after(interval, &block) timer.after(interval, &block) end |
#alive? ⇒ TrueClass, FalseClass
316 317 318 |
# File 'lib/zoidberg/shell.rb', line 316 def alive? !respond_to?(:_zoidberg_destroyed) end |
#broadcast(name, arg = nil) ⇒ TrueClass, FalseClass
Broadcast a signal to all waiters
302 303 304 |
# File 'lib/zoidberg/shell.rb', line 302 def broadcast(name, arg=nil) _zoidberg_signal_interface.broadcast(*[name, arg].compact) end |
#every(interval) { ... } ⇒ Timer
Register a recurring action
276 277 278 |
# File 'lib/zoidberg/shell.rb', line 276 def every(interval, &block) timer.every(interval, &block) end |
#link(inst) ⇒ TrueClass
Link given shelled instance to current shelled instance to handle any exceptions raised from async actions
342 343 344 345 |
# File 'lib/zoidberg/shell.rb', line 342 def link(inst) inst._zoidberg_link = current_self true end |
#signal(name, arg = nil) ⇒ TrueClass, FalseClass
Send a signal to single waiter
294 295 296 |
# File 'lib/zoidberg/shell.rb', line 294 def signal(name, arg=nil) _zoidberg_signal_interface.signal(*[name, arg].compact) end |
#timer ⇒ Timer
267 268 269 |
# File 'lib/zoidberg/shell.rb', line 267 def timer _zoidberg_proxy._zoidberg_timer end |
#wait_for(name) ⇒ Object Also known as: wait
Wait for a given signal
310 311 312 |
# File 'lib/zoidberg/shell.rb', line 310 def wait_for(name) defer{ _zoidberg_signal_interface.wait_for(name) } end |