Skip to content

Commit 7d3d154

Browse files
committed
remove dependency of Pausing on Supervised
1 parent 67a0730 commit 7d3d154

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

lib/concurrent/actor/behaviour/pausing.rb

+4-12
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ def initialize(core, subsequent)
1717
def on_envelope(envelope)
1818
case envelope.message
1919
when :pause!
20-
from_supervisor?(envelope) { pause! }
20+
pause!
2121
when :resume!
22-
from_supervisor?(envelope) { resume! }
22+
resume!
2323
when :reset!
24-
from_supervisor?(envelope) { reset! }
24+
reset!
2525
when :restart!
26-
from_supervisor?(envelope) { restart! }
26+
restart!
2727
else
2828
if @paused
2929
@buffer << envelope
@@ -34,14 +34,6 @@ def on_envelope(envelope)
3434
end
3535
end
3636

37-
def from_supervisor?(envelope)
38-
if behaviour!(Supervised).supervisor == envelope.sender
39-
yield
40-
else
41-
false
42-
end
43-
end
44-
4537
def pause!(error = nil)
4638
@paused = true
4739
broadcast(error || :paused)

lib/concurrent/actor/behaviour/supervised.rb

+7
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ def on_envelope(envelope)
2020
supervisor
2121
when :un_supervise
2222
un_supervise envelope.sender
23+
when :pause!, :resume!, :reset!, :restart!
24+
# allow only supervisor to control the actor
25+
if @supervisor == envelope.sender
26+
pass envelope
27+
else
28+
false
29+
end
2330
else
2431
pass envelope
2532
end

0 commit comments

Comments
 (0)