@@ -118,6 +118,8 @@ def post_on(executor, *args, &job)
118
118
119
119
# Represents an event which will happen in future (will be completed). It has to always happen.
120
120
class Event < Synchronization ::Object
121
+ include Concern ::Deprecation
122
+
121
123
def initialize ( promise , default_executor )
122
124
@Promise = promise
123
125
@DefaultExecutor = default_executor
@@ -140,6 +142,10 @@ def pending?(state = @State.get)
140
142
state == :pending
141
143
end
142
144
145
+ def unscheduled?
146
+ raise 'unsupported'
147
+ end
148
+
143
149
alias_method :incomplete? , :pending?
144
150
145
151
# Has the Event been completed?
@@ -228,6 +234,11 @@ def inspect
228
234
"#{ to_s [ 0 ..-2 ] } blocks:[#{ blocks . map ( &:to_s ) . join ( ', ' ) } ]>"
229
235
end
230
236
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
+
231
242
# @!visibility private
232
243
def complete ( raise_on_reassign = true )
233
244
if complete_state
@@ -371,18 +382,33 @@ def success?(state = @State.get)
371
382
Success === state
372
383
end
373
384
385
+ def fulfilled?
386
+ deprecated_method 'fulfilled?' , 'success?'
387
+ success?
388
+ end
389
+
374
390
# Has Future been failed?
375
391
# @return [Boolean]
376
392
def failed? ( state = @State . get )
377
393
Failed === state
378
394
end
379
395
396
+ def rejected?
397
+ deprecated_method 'rejected?' , 'failed?'
398
+ failed?
399
+ end
400
+
380
401
# Has the Future been completed?
381
402
# @return [Boolean]
382
- def completed ?( state = @State . get )
403
+ def complete ?( state = @State . get )
383
404
success? state or failed? state
384
405
end
385
406
407
+ def completed? ( state = @State . get )
408
+ deprecated_method 'completed?' , 'complete?'
409
+ complete? state
410
+ end
411
+
386
412
# @return [Object] the value of the Future when success
387
413
def value ( timeout = nil )
388
414
touch
0 commit comments