Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: register a promise as waiting_work only if it is being executed #318

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/roby/promise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ def initialize(
executor: execution_engine.thread_pool, description: "promise", &block
)
@execution_engine = execution_engine
execution_engine.waiting_work << self
@description = description

@pipeline = []
Expand Down Expand Up @@ -260,6 +259,7 @@ def fail(exception = StandardError)
end

def execute
execution_engine.waiting_work << self
promise.execute
self
end
Expand Down
7 changes: 6 additions & 1 deletion test/test_execution_engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,13 @@ module Roby
end

describe "promise handling" do
it "queues promises in the #waiting_work list" do
it "does not queue a promise in #waiting_work on creation" do
p = execution_engine.promise {}
refute execution_engine.waiting_work.include?(p)
end

it "queues a promise in #waiting_work on execution" do
p = execution_engine.promise {}.execute
assert execution_engine.waiting_work.include?(p)
end

Expand Down
4 changes: 0 additions & 4 deletions test/test_promise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ module Roby
before do
@recorder = flexmock
end
it "registers the promise as pending work on the engine" do
p = execution_engine.promise {}
assert execution_engine.waiting_work.include?(p)
end

it "executes the promised work" do
recorder.should_receive(:called).once
Expand Down