Fix local variable names to reflect type
This commit is contained in:
parent
9b73524098
commit
cb1047224c
5 changed files with 19 additions and 19 deletions
|
@ -42,7 +42,7 @@ module Mutant
|
|||
|
||||
# Binding to othersactors sender for simple RPC
|
||||
class Binding
|
||||
include Concord.new(:actor, :other)
|
||||
include Concord.new(:mailbox, :other)
|
||||
|
||||
# Send message and wait for reply
|
||||
#
|
||||
|
@ -53,8 +53,8 @@ module Mutant
|
|||
# @api private
|
||||
#
|
||||
def call(type)
|
||||
other.call(Message.new(type, actor.sender))
|
||||
message = actor.receiver.call
|
||||
other.call(Message.new(type, mailbox.sender))
|
||||
message = mailbox.receiver.call
|
||||
fail ProtocolError, "Expected #{type} but got #{message.type}" unless type.equal?(message.type)
|
||||
message.payload
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@ module Mutant
|
|||
module Parallel
|
||||
# Master parallel worker
|
||||
class Master
|
||||
include Concord.new(:config, :actor)
|
||||
include Concord.new(:config, :mailbox)
|
||||
|
||||
private_class_method :new
|
||||
|
||||
|
@ -15,8 +15,8 @@ module Mutant
|
|||
# @api private
|
||||
#
|
||||
def self.call(config)
|
||||
config.env.spawn do |actor|
|
||||
new(config, actor).__send__(:run)
|
||||
config.env.spawn do |mailbox|
|
||||
new(config, mailbox).__send__(:run)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -46,11 +46,11 @@ module Mutant
|
|||
def run
|
||||
config.jobs.times do
|
||||
@workers += 1
|
||||
config.env.spawn do |worker_actor|
|
||||
config.env.spawn do |worker_mailbox|
|
||||
Worker.run(
|
||||
actor: worker_actor,
|
||||
mailbox: worker_mailbox,
|
||||
processor: config.processor,
|
||||
parent: actor.sender
|
||||
parent: mailbox.sender
|
||||
)
|
||||
end
|
||||
end
|
||||
|
@ -88,7 +88,7 @@ module Mutant
|
|||
# @api private
|
||||
#
|
||||
def receive_loop
|
||||
handle(actor.receiver.call) until @workers.zero? && @stop
|
||||
handle(mailbox.receiver.call) until @workers.zero? && @stop
|
||||
end
|
||||
|
||||
# Handle status
|
||||
|
|
|
@ -2,7 +2,7 @@ module Mutant
|
|||
module Parallel
|
||||
# Parallel execution worker
|
||||
class Worker
|
||||
include Adamantium::Flat, Anima.new(:actor, :processor, :parent)
|
||||
include Adamantium::Flat, Anima.new(:mailbox, :processor, :parent)
|
||||
|
||||
# Run worker
|
||||
#
|
||||
|
@ -29,8 +29,8 @@ module Mutant
|
|||
#
|
||||
def run
|
||||
begin
|
||||
parent.call(Actor::Message.new(:ready, actor.sender))
|
||||
end until handle(actor.receiver.call)
|
||||
parent.call(Actor::Message.new(:ready, mailbox.sender))
|
||||
end until handle(mailbox.receiver.call)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -83,7 +83,7 @@ RSpec.describe Mutant::Parallel::Master do
|
|||
|
||||
before do
|
||||
expect(Mutant::Parallel::Worker).to receive(:run).with(
|
||||
actor: actor_env.mailbox(:worker_a),
|
||||
mailbox: actor_env.mailbox(:worker_a),
|
||||
processor: processor,
|
||||
parent: actor_env.mailbox(:master).sender
|
||||
).and_return(worker_a)
|
||||
|
@ -97,7 +97,7 @@ RSpec.describe Mutant::Parallel::Master do
|
|||
|
||||
before do
|
||||
expect(Mutant::Parallel::Worker).to receive(:run).with(
|
||||
actor: actor_env.mailbox(:worker_b),
|
||||
mailbox: actor_env.mailbox(:worker_b),
|
||||
processor: processor,
|
||||
parent: actor_env.mailbox(:master).sender
|
||||
).and_return(worker_b)
|
||||
|
|
|
@ -5,7 +5,7 @@ RSpec.describe Mutant::Parallel::Worker do
|
|||
|
||||
let(:message_sequence) { FakeActor::MessageSequence.new }
|
||||
let(:processor) { double('Processor') }
|
||||
let(:actor) { actor_env.mailbox(:worker) }
|
||||
let(:mailbox) { actor_env.mailbox(:worker) }
|
||||
let(:parent) { actor_env.mailbox(:parent).sender }
|
||||
let(:payload) { double('Payload') }
|
||||
let(:result_payload) { double('Result Payload') }
|
||||
|
@ -14,12 +14,12 @@ RSpec.describe Mutant::Parallel::Worker do
|
|||
{
|
||||
processor: processor,
|
||||
parent: parent,
|
||||
actor: actor
|
||||
mailbox: mailbox
|
||||
}
|
||||
end
|
||||
|
||||
before do
|
||||
message_sequence.add(:parent, :ready, actor.sender)
|
||||
message_sequence.add(:parent, :ready, mailbox.sender)
|
||||
end
|
||||
|
||||
describe '.run' do
|
||||
|
@ -36,7 +36,7 @@ RSpec.describe Mutant::Parallel::Worker do
|
|||
|
||||
message_sequence.add(:worker, :job, job)
|
||||
message_sequence.add(:parent, :result, job_result)
|
||||
message_sequence.add(:parent, :ready, actor.sender)
|
||||
message_sequence.add(:parent, :ready, mailbox.sender)
|
||||
message_sequence.add(:worker, :stop)
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue