A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Actor/Behaviour/Pausing.html below:

Class: Concurrent::Actor::Behaviour::Pausing — Concurrent Ruby

Class: Concurrent::Actor::Behaviour::Pausing
Inherits:
Abstract show all
Defined in:
lib/concurrent-ruby-edge/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 Method Summary collapse Constructor Details #initialize(core, subsequent, core_options) ⇒ Pausing

Returns a new instance of Pausing.

13
14
15
16
17
# File 'lib/concurrent-ruby-edge/concurrent/actor/behaviour/pausing.rb', line 13

def initialize(core, subsequent, core_options)
  super core, subsequent, core_options
  @paused   = false
  @deferred = []
end
Instance Method Details #on_envelope(envelope) ⇒ undocumented
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/concurrent-ruby-edge/concurrent/actor/behaviour/pausing.rb', line 23

def on_envelope(envelope)
  case envelope.message
  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
#on_event(public, event) ⇒ undocumented
74
75
76
77
78
# File 'lib/concurrent-ruby-edge/concurrent/actor/behaviour/pausing.rb', line 74

def on_event(public, event)
  event_name, _ = event
  reject_deferred if event_name == :terminated
  super public, event
end
#pause!(error = nil) ⇒ undocumented
45
46
47
48
49
# File 'lib/concurrent-ruby-edge/concurrent/actor/behaviour/pausing.rb', line 45

def pause!(error = nil)
  do_pause
  broadcast true, error || :paused
  true
end
#paused? ⇒ Boolean
19
20
21
# File 'lib/concurrent-ruby-edge/concurrent/actor/behaviour/pausing.rb', line 19

def paused?
  @paused
end
#reset! ⇒ undocumented
58
59
60
61
62
63
64
# File 'lib/concurrent-ruby-edge/concurrent/actor/behaviour/pausing.rb', line 58

def reset!
  return false unless paused?
  broadcast(false, :resetting)
  do_reset
  broadcast(true, :reset)
  true
end
#restart! ⇒ undocumented
66
67
68
69
70
71
72
# File 'lib/concurrent-ruby-edge/concurrent/actor/behaviour/pausing.rb', line 66

def restart!
  return false unless paused?
  broadcast(false, :restarting)
  do_restart
  broadcast(true, :restarted)
  true
end
#resume! ⇒ undocumented
51
52
53
54
55
56
# File 'lib/concurrent-ruby-edge/concurrent/actor/behaviour/pausing.rb', line 51

def resume!
  return false unless paused?
  do_resume
  broadcast(true, :resumed)
  true
end

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4