Class: Dramatis::Runtime::Actor::Main

Inherits:
Dramatis::Runtime::Actor show all
Defined in:
lib/dramatis/runtime/actor.rb

Overview

Might be nice if this was broken out into another file … YAGNI? This needs to be reworked. External threads and the main thread are related but different (there can only be one main thread). Mutliple at_exit calls are suspect. Of course, if the main actor tracks multilple runtimes, it might be okay.

Defined Under Namespace

Classes: DefaultBehavior

Constant Summary collapse

@@current =
nil

Instance Attribute Summary

Attributes inherited from Dramatis::Runtime::Actor

#call_thread, #gate, #object, #object_interface

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Dramatis::Runtime::Actor

#actor_send, #bind, #blocked!, #call_threading?, #common_send, #current_call_thread?, #deadlock, #deliver, #enable_call_threading, #exception, #name, #object_initialize, #object_send, #register_continuation, #runnable!, #runnable?, #schedule, #timeout, #yield

Constructor Details

#initializeMain

Returns a new instance of Main.



287
288
289
290
291
292
# File 'lib/dramatis/runtime/actor.rb', line 287

def initialize
  super DefaultBehavior.new
  @at_exit_run = false
  at_exit { finalize }
  runnable!
end

Class Method Details

.currentObject



267
268
269
# File 'lib/dramatis/runtime/actor.rb', line 267

def self.current
  @@current ||= self.new
end

.resetObject



271
272
273
# File 'lib/dramatis/runtime/actor.rb', line 271

def self.reset
  @@current = nil
end

Instance Method Details

#finalizeObject



279
280
281
282
283
284
285
# File 'lib/dramatis/runtime/actor.rb', line 279

def finalize
  if !@at_exit_run
    @at_exit_run = true
    schedule
    Dramatis::Runtime::Scheduler.current.main_at_exit
  end
end

#quiesceObject



275
276
277
# File 'lib/dramatis/runtime/actor.rb', line 275

def quiesce
  schedule
end