Class: Concurrent::Actor::Behaviour::Pausing
- Inherits:
-
Abstract
- Object
- Abstract
- Concurrent::Actor::Behaviour::Pausing
- Defined in:
- lib/concurrent/actor/behaviour/pausing.rb
Overview
Note:
TODO missing example
Allows to pause actors on errors. When paused all arriving messages are collected and processed after the actor is resumed or reset. Resume will simply continue with next message. Reset also reinitialized context.
Instance Attribute Summary (collapse)
- - (undocumented) core inherited from Abstract readonly
- - (undocumented) subsequent inherited from Abstract readonly
Instance Method Summary (collapse)
-
- (Pausing) initialize(core, subsequent, core_options)
constructor
A new instance of Pausing.
- - (undocumented) on_envelope(envelope)
- - (undocumented) on_event(public, event)
- - (undocumented) pause!(error = nil)
- - (Boolean) paused?
- - (undocumented) reset!
- - (undocumented) restart!
- - (undocumented) resume!
Constructor Details
- (Pausing) initialize(core, subsequent, core_options)
Returns a new instance of Pausing
11 12 13 14 15 |
# File 'lib/concurrent/actor/behaviour/pausing.rb', line 11 def initialize(core, subsequent, ) super core, subsequent, @paused = false @deferred = [] end |
Instance Attribute Details
- (undocumented) core (readonly) Originally defined in class Abstract
- (undocumented) subsequent (readonly) Originally defined in class Abstract
Instance Method Details
- (undocumented) on_envelope(envelope)
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/concurrent/actor/behaviour/pausing.rb', line 21 def on_envelope(envelope) case envelope. when :pause! pause! when :paused? paused? when :resume! resume! when :reset! reset! when :restart! restart! else if paused? @deferred << envelope MESSAGE_PROCESSED else pass envelope end end end |
- (undocumented) on_event(public, event)
72 73 74 75 76 |
# File 'lib/concurrent/actor/behaviour/pausing.rb', line 72 def on_event(public, event) event_name, _ = event reject_deferred if event_name == :terminated super public, event end |
- (undocumented) pause!(error = nil)
43 44 45 46 47 |
# File 'lib/concurrent/actor/behaviour/pausing.rb', line 43 def pause!(error = nil) do_pause broadcast true, error || :paused true end |
- (Boolean) paused?
17 18 19 |
# File 'lib/concurrent/actor/behaviour/pausing.rb', line 17 def paused? @paused end |
- (undocumented) reset!
56 57 58 59 60 61 62 |
# File 'lib/concurrent/actor/behaviour/pausing.rb', line 56 def reset! return false unless paused? broadcast(false, :resetting) do_reset broadcast(true, :reset) true end |
- (undocumented) restart!
64 65 66 67 68 69 70 |
# File 'lib/concurrent/actor/behaviour/pausing.rb', line 64 def restart! return false unless paused? broadcast(false, :restarting) do_restart broadcast(true, :restarted) true end |
- (undocumented) resume!
49 50 51 52 53 54 |
# File 'lib/concurrent/actor/behaviour/pausing.rb', line 49 def resume! return false unless paused? do_resume broadcast(true, :resumed) true end |