Skip to content

Commit 2a8e408

Browse files
committed
Use always behaviour_definition instead just behaviour
1 parent 30a2a8e commit 2a8e408

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

lib/concurrent/actor/behaviour.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ module Behaviour
3131
require 'concurrent/actor/behaviour/termination'
3232
require 'concurrent/actor/behaviour/terminates_children'
3333

34-
def self.basic_behaviour
34+
def self.basic_behaviour_definition
3535
[*base,
3636
*user_messages(:terminate)]
3737
end
3838

39-
def self.restarting_behaviour
39+
def self.restarting_behaviour_definition
4040
[*base,
4141
*supervising,
4242
*user_messages(:pause)]

lib/concurrent/actor/context.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def self.spawn_optionify(name_or_opts, *args)
122122
# Ping.spawn(:ping1).ask(:m).value #=> :m
123123
class Context < AbstractContext
124124
def behaviour_definition
125-
Behaviour.basic_behaviour
125+
Behaviour.basic_behaviour_definition
126126
end
127127
end
128128

@@ -136,7 +136,7 @@ def behaviour_definition
136136
# TODO usage
137137
class RestartingContext < AbstractContext
138138
def behaviour_definition
139-
Behaviour.restarting_behaviour
139+
Behaviour.restarting_behaviour_definition
140140
end
141141
end
142142
end

lib/concurrent/actor/core.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class Core
3535
# @option opts [Executor] executor, default is `Concurrent.configuration.global_task_pool`
3636
# @option opts [true, false] link, atomically link the actor to its parent
3737
# @option opts [true, false] supervise, atomically supervise the actor by its parent
38-
# @option opts [[Array<Array(Behavior::Abstract, Array<Object>)>]] behaviour, array of pairs
38+
# @option opts [Array<Array(Behavior::Abstract, Array<Object>)>] behaviour_definition, array of pairs
3939
# where each pair is behaviour class and its args, see {Behaviour.basic_behaviour}
4040
# @option opts [IVar, nil] initialized, if present it'll be set or failed after {Context} initialization
4141
# @option opts [Proc, nil] logger a proc accepting (level, progname, message = nil, &block) params,
@@ -210,7 +210,7 @@ def handle_envelope(envelope)
210210
end
211211

212212
def initialize_behaviours(opts)
213-
@behaviour_definition = (Type! opts[:behaviour] || @context.behaviour_definition, Array).each do |v|
213+
@behaviour_definition = (Type! opts[:behaviour_definition] || @context.behaviour_definition, Array).each do |v|
214214
Type! v, Array
215215
Match! v.size, 2
216216
Child! v[0], Behaviour::Abstract

spec/concurrent/actor_spec.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,8 @@ def on_message(message)
279279
it 'pauses on error' do
280280
queue = Queue.new
281281
test = AdHoc.spawn :tester do
282-
actor = AdHoc.spawn name: :pausing, behaviour: Behaviour.restarting_behaviour do
282+
actor = AdHoc.spawn name: :pausing,
283+
behaviour_definition: Behaviour.restarting_behaviour_definition do
283284
queue << :init
284285
-> m { m == :add ? 1 : pass }
285286
end
@@ -306,7 +307,9 @@ def on_message(message)
306307
terminate_actors test
307308

308309
test = AdHoc.spawn :tester do
309-
actor = AdHoc.spawn name: :pausing, supervise: true, behaviour: Behaviour.restarting_behaviour do
310+
actor = AdHoc.spawn name: :pausing,
311+
supervise: true,
312+
behaviour_definition: Behaviour.restarting_behaviour_definition do
310313
queue << :init
311314
-> m { m == :add ? 1 : pass }
312315
end

0 commit comments

Comments
 (0)