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
312 313 314 315 316 317 318 319 320 321 |
# File 'lib/zoidberg/shell.rb', line 312 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
250 251 252 |
# File 'lib/zoidberg/shell.rb', line 250 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)
340 341 342 343 344 345 346 347 348 |
# File 'lib/zoidberg/shell.rb', line 340 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
273 274 275 |
# File 'lib/zoidberg/shell.rb', line 273 def after(interval, &block) timer.after(interval, &block) end |
#alive? ⇒ TrueClass, FalseClass
304 305 306 |
# File 'lib/zoidberg/shell.rb', line 304 def alive? !respond_to?(:_zoidberg_destroyed) end |
#broadcast(name, arg = nil) ⇒ TrueClass, FalseClass
Broadcast a signal to all waiters
290 291 292 |
# File 'lib/zoidberg/shell.rb', line 290 def broadcast(name, arg=nil) _zoidberg_signal_interface.broadcast(*[name, arg].compact) end |
#every(interval) { ... } ⇒ Timer
Register a recurring action
264 265 266 |
# File 'lib/zoidberg/shell.rb', line 264 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
330 331 332 333 |
# File 'lib/zoidberg/shell.rb', line 330 def link(inst) inst._zoidberg_link = current_self true end |
#signal(name, arg = nil) ⇒ TrueClass, FalseClass
Send a signal to single waiter
282 283 284 |
# File 'lib/zoidberg/shell.rb', line 282 def signal(name, arg=nil) _zoidberg_signal_interface.signal(*[name, arg].compact) end |
#timer ⇒ Timer
255 256 257 |
# File 'lib/zoidberg/shell.rb', line 255 def timer _zoidberg_proxy._zoidberg_timer end |
#wait_for(name) ⇒ Object Also known as: wait
Wait for a given signal
298 299 300 |
# File 'lib/zoidberg/shell.rb', line 298 def wait_for(name) defer{ _zoidberg_signal_interface.wait_for(name) } end |