Skip to content

Commit f1cea8b

Browse files
committed
BlockedPromise always takes an array of futures
1 parent 278cdae commit f1cea8b

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lib/concurrent/promises.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,10 @@ def inspect
10491049
private
10501050

10511051
def initialize_blocked_by(blocked_by_futures)
1052-
@BlockedBy = [blocked_by_futures].flatten
1052+
unless blocked_by_futures.is_a?(::Array)
1053+
raise ArgumentError, "has to be array of events/futures: #{blocked_by_futures.inspect}"
1054+
end
1055+
@BlockedBy = blocked_by_futures
10531056
end
10541057

10551058
def clear_blocked_by!
@@ -1076,7 +1079,7 @@ def on_completable(done_future)
10761079
class BlockedTaskPromise < BlockedPromise
10771080
def initialize(blocked_by_future, default_executor, executor, args, &task)
10781081
raise ArgumentError, 'no block given' unless block_given?
1079-
super Future.new(self, default_executor), blocked_by_future, 1
1082+
super Future.new(self, default_executor), [blocked_by_future], 1
10801083
@Executor = executor
10811084
@Task = task
10821085
@Args = args
@@ -1255,7 +1258,7 @@ def on_completable(done_future)
12551258

12561259
class EventWrapperPromise < BlockedPromise
12571260
def initialize(event, default_executor)
1258-
super Event.new(self, default_executor), event, 1
1261+
super Event.new(self, default_executor), [event], 1
12591262
end
12601263

12611264
def on_completable(done_future)
@@ -1265,7 +1268,7 @@ def on_completable(done_future)
12651268

12661269
class FutureWrapperPromise < BlockedPromise
12671270
def initialize(future, default_executor)
1268-
super Future.new(self, default_executor), future, 1
1271+
super Future.new(self, default_executor), [future], 1
12691272
end
12701273

12711274
def on_completable(done_future)

0 commit comments

Comments
 (0)