Skip to content

Commit 162b7c1

Browse files
committed
Use ns_wait_until
1 parent f92204a commit 162b7c1

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

lib/concurrent/edge/future.rb

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def completed?
9191
# @param [Numeric] timeout the maximum time in second to wait.
9292
# @return [Obligation] self
9393
def wait(timeout = nil)
94-
synchronize { ns_wait(timeout) }
94+
synchronize { ns_wait_until_complete(timeout) }
9595
end
9696

9797
def touch
@@ -184,7 +184,7 @@ def with_default_executor(executor = default_executor)
184184
AllPromise.new([self], executor).future
185185
end
186186

187-
protected
187+
private
188188

189189
def ns_initialize(promise, default_executor = :fast)
190190
@promise = promise
@@ -194,9 +194,9 @@ def ns_initialize(promise, default_executor = :fast)
194194
@touched = false
195195
end
196196

197-
def ns_wait(timeout = nil)
197+
def ns_wait_until_complete(timeout = nil)
198198
ns_touch
199-
super timeout if ns_incomplete?
199+
ns_wait_until(timeout) { ns_completed? }
200200
self
201201
end
202202

@@ -234,11 +234,11 @@ def pr_chain(default_executor, executor = nil, &callback)
234234
end
235235

236236
def pr_delay(default_executor)
237-
self.pr_join(default_executor, Delay.new(default_executor).future)
237+
pr_join(default_executor, Delay.new(default_executor).future)
238238
end
239239

240240
def pr_schedule(default_executor, intended_time)
241-
self.pr_chain(default_executor) { ScheduledPromise.new(intended_time).future.join(self) }.flat
241+
pr_chain(default_executor) { ScheduledPromise.new(intended_time).future.join(self) }.flat
242242
end
243243

244244
def pr_join(default_executor, *futures)
@@ -279,8 +279,6 @@ def ns_add_callback(method, *args)
279279
self
280280
end
281281

282-
private
283-
284282
def ns_complete_state
285283
@state = :completed
286284
end
@@ -350,7 +348,7 @@ def reason(timeout = nil)
350348
# @return [Obligation] self
351349
# @raise [Exception] when #failed? it raises #reason
352350
def wait!(timeout = nil)
353-
synchronize { ns_wait! timeout }
351+
synchronize { ns_wait_until_complete! timeout }
354352
end
355353

356354
# @raise [Exception] when #failed? it raises #reason
@@ -427,7 +425,7 @@ def ns_add_callback(method, *args)
427425
self
428426
end
429427

430-
protected
428+
private
431429

432430
def ns_initialize(promise, default_executor = :fast)
433431
super(promise, default_executor)
@@ -448,23 +446,23 @@ def ns_completed?
448446
end
449447

450448
def ns_value(timeout = nil)
451-
ns_wait timeout
449+
ns_wait_until_complete timeout
452450
@value
453451
end
454452

455453
def ns_reason(timeout = nil)
456-
ns_wait timeout
454+
ns_wait_until_complete timeout
457455
@reason
458456
end
459457

460-
def ns_wait!(timeout = nil)
461-
ns_wait(timeout)
458+
def ns_wait_until_complete!(timeout = nil)
459+
ns_wait_until_complete(timeout)
462460
raise self if ns_failed?
463461
self
464462
end
465463

466464
def ns_value!(timeout = nil)
467-
ns_wait!(timeout)
465+
ns_wait_until_complete!(timeout)
468466
@value
469467
end
470468

0 commit comments

Comments
 (0)