Class Dramatis::Runtime
In: lib/dramatis/runtime/actor/main.rb
lib/dramatis/runtime/task.rb
lib/dramatis/runtime/gate.rb
lib/dramatis/runtime/scheduler.rb
lib/dramatis/runtime/actor.rb
lib/dramatis/runtime/thread_pool.rb
lib/dramatis/runtime/timer.rb
lib/dramatis/runtime.rb
Parent: Object

Dramatis::Runtime is the top level class managing the running of the various pieces of the dramatis runtime. Typically programs don‘t need to deal with the runtime directly, though some functions are useful, particularly for debugging and testing.

Methods

Public Class methods

Returns a reference to the current Dramatis::Runtime object.

[Source]

    # File lib/dramatis/runtime.rb, line 17
17:   def self.current
18:     @@current ||= self.new
19:   end

Resets the current runtime instance. Note that this method hard resets counters and ignores exceptions which is generally a bad idea. It is typical only used in unit test and spec "after" methods to keep failing tests from cascading.

[Source]

    # File lib/dramatis/runtime.rb, line 29
29:   def self.reset
30:     # this swallows exceptions: it's assumed to be used to clean up
31:     # a failed test so there's no connection between tests
32:     begin
33:       Dramatis::Runtime.current.quiesce
34:     rescue Exception => e
35:     end
36:     Dramatis::Runtime::Scheduler.reset    
37:     Dramatis::Runtime::Actor::Main.reset    
38:     @@current = nil
39:   end

Public Instance methods

Clears the list of uncaught exceptions. Used in unit tests and specs to clear expected exceptions. If exceptions are raised and not cleared, they will be raised at the end of the program via a Dramatis::Error::Uncaught.

[Source]

     # File lib/dramatis/runtime.rb, line 95
 95:   def clear_exceptions
 96:     @mutex.synchronize do
 97:       # warn "runtime clearing exceptions"
 98:       @exceptions.clear
 99:     end
100:   end

Returns the list of exceptions that were not caught by an actor.

[Source]

    # File lib/dramatis/runtime.rb, line 79
79:   def exceptions 
80:     result = nil
81:     @mutex.synchronize do
82:       result = @exceptions.dup
83:     end
84:     result
85:   end

Causes the runtime to suspend the current thread until there are no more tasks that can be executed. If no tasks remain, returns normally. If tasks remain but are gated off, Dramatis::Deadlock is raised.

As a side effect, this method releases the current actor to process messages but does not change the task gate.

[Source]

    # File lib/dramatis/runtime.rb, line 52
52:   def quiesce
53:     Dramatis::Runtime::Scheduler.current.quiesce
54:     maybe_raise_exceptions true
55:   end

Enables or disables printing warnings, e.g., when uncaught exceptions are detected. Returns the value passed.

[Source]

     # File lib/dramatis/runtime.rb, line 125
125:   def warnings= value
126:     @warnings = value
127:   end

Returns true if warnings are enabled.

[Source]

     # File lib/dramatis/runtime.rb, line 134
134:   def warnings?
135:     @warnings
136:   end

[Validate]