Class: Phronomy::Agent::ActivationRegistry
- Inherits:
-
Object
- Object
- Phronomy::Agent::ActivationRegistry
- Defined in:
- lib/phronomy/agent/activation_registry.rb
Instance Method Summary collapse
- #delete(execution_id) ⇒ Object
- #fetch(execution_id) ⇒ Object
-
#initialize ⇒ ActivationRegistry
constructor
A new instance of ActivationRegistry.
- #register(activation) ⇒ Object
Constructor Details
#initialize ⇒ ActivationRegistry
Returns a new instance of ActivationRegistry.
6 7 8 9 |
# File 'lib/phronomy/agent/activation_registry.rb', line 6 def initialize @mutex = Mutex.new @records = {} end |
Instance Method Details
#delete(execution_id) ⇒ Object
23 24 25 |
# File 'lib/phronomy/agent/activation_registry.rb', line 23 def delete(execution_id) @mutex.synchronize { @records.delete(execution_id.to_s) } end |
#fetch(execution_id) ⇒ Object
19 20 21 |
# File 'lib/phronomy/agent/activation_registry.rb', line 19 def fetch(execution_id) @mutex.synchronize { @records[execution_id.to_s] } end |
#register(activation) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/phronomy/agent/activation_registry.rb', line 11 def register(activation) @mutex.synchronize do raise ArgumentError, "activation already registered: #{activation.execution_id}" if @records.key?(activation.execution_id) @records[activation.execution_id] = activation end activation end |