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
326 327 328 329 330 331 332 333 334 335 |
# File 'lib/zoidberg/shell.rb', line 326 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
264 265 266 |
# File 'lib/zoidberg/shell.rb', line 264 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)
354 355 356 357 358 359 360 361 362 |
# File 'lib/zoidberg/shell.rb', line 354 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
287 288 289 |
# File 'lib/zoidberg/shell.rb', line 287 def after(interval, &block) timer.after(interval, &block) end |
#alive? ⇒ TrueClass, FalseClass
318 319 320 |
# File 'lib/zoidberg/shell.rb', line 318 def alive? !respond_to?(:_zoidberg_destroyed) end |
#broadcast(name, arg = nil) ⇒ TrueClass, FalseClass
Broadcast a signal to all waiters
304 305 306 |
# File 'lib/zoidberg/shell.rb', line 304 def broadcast(name, arg=nil) _zoidberg_signal_interface.broadcast(*[name, arg].compact) end |
#every(interval) { ... } ⇒ Timer
Register a recurring action
278 279 280 |
# File 'lib/zoidberg/shell.rb', line 278 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
344 345 346 347 |
# File 'lib/zoidberg/shell.rb', line 344 def link(inst) inst._zoidberg_link = current_self true end |
#signal(name, arg = nil) ⇒ TrueClass, FalseClass
Send a signal to single waiter
296 297 298 |
# File 'lib/zoidberg/shell.rb', line 296 def signal(name, arg=nil) _zoidberg_signal_interface.signal(*[name, arg].compact) end |
#timer ⇒ Timer
269 270 271 |
# File 'lib/zoidberg/shell.rb', line 269 def timer _zoidberg_proxy._zoidberg_timer end |
#wait_for(name) ⇒ Object Also known as: wait
Wait for a given signal
312 313 314 |
# File 'lib/zoidberg/shell.rb', line 312 def wait_for(name) defer{ _zoidberg_signal_interface.wait_for(name) } end |