Skip to content

Commit a71760e

Browse files
committed
Add deprecated methods to Event/Future
1 parent f03d983 commit a71760e

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

lib/concurrent/edge/future.rb

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ def post_on(executor, *args, &job)
118118

119119
# Represents an event which will happen in future (will be completed). It has to always happen.
120120
class Event < Synchronization::Object
121+
include Concern::Deprecation
122+
121123
def initialize(promise, default_executor)
122124
@Promise = promise
123125
@DefaultExecutor = default_executor
@@ -140,6 +142,10 @@ def pending?(state = @State.get)
140142
state == :pending
141143
end
142144

145+
def unscheduled?
146+
raise 'unsupported'
147+
end
148+
143149
alias_method :incomplete?, :pending?
144150

145151
# Has the Event been completed?
@@ -228,6 +234,11 @@ def inspect
228234
"#{to_s[0..-2]} blocks:[#{blocks.map(&:to_s).join(', ')}]>"
229235
end
230236

237+
def set(*args, &block)
238+
raise 'Use CompletableEvent#complete or CompletableFuture#complete instead, ' +
239+
'constructed by Concurrent.event or Concurrent.future respectively.'
240+
end
241+
231242
# @!visibility private
232243
def complete(raise_on_reassign = true)
233244
if complete_state
@@ -371,18 +382,33 @@ def success?(state = @State.get)
371382
Success === state
372383
end
373384

385+
def fulfilled?
386+
deprecated_method 'fulfilled?', 'success?'
387+
success?
388+
end
389+
374390
# Has Future been failed?
375391
# @return [Boolean]
376392
def failed?(state = @State.get)
377393
Failed === state
378394
end
379395

396+
def rejected?
397+
deprecated_method 'rejected?', 'failed?'
398+
failed?
399+
end
400+
380401
# Has the Future been completed?
381402
# @return [Boolean]
382-
def completed?(state = @State.get)
403+
def complete?(state = @State.get)
383404
success? state or failed? state
384405
end
385406

407+
def completed?(state = @State.get)
408+
deprecated_method 'completed?', 'complete?'
409+
complete? state
410+
end
411+
386412
# @return [Object] the value of the Future when success
387413
def value(timeout = nil)
388414
touch

0 commit comments

Comments
 (0)