@@ -259,6 +259,7 @@ def any_event_on(default_executor, *futures_and_or_events)
259
259
end
260
260
261
261
module InternalStates
262
+ # @private
262
263
class State
263
264
def completed?
264
265
raise NotImplementedError
@@ -271,6 +272,7 @@ def to_sym
271
272
272
273
private_constant :State
273
274
275
+ # @private
274
276
class Pending < State
275
277
def completed?
276
278
false
@@ -283,6 +285,7 @@ def to_sym
283
285
284
286
private_constant :Pending
285
287
288
+ # @private
286
289
class CompletedWithResult < State
287
290
def completed?
288
291
true
@@ -315,8 +318,9 @@ def apply
315
318
316
319
private_constant :CompletedWithResult
317
320
318
- # @!visibility private
321
+ # @private
319
322
class Success < CompletedWithResult
323
+
320
324
def initialize ( value )
321
325
@Value = value
322
326
end
@@ -344,7 +348,7 @@ def to_sym
344
348
345
349
private_constant :Success
346
350
347
- # @!visibility private
351
+ # @private
348
352
class SuccessArray < Success
349
353
def apply ( args , block )
350
354
block . call ( *value , *args )
@@ -353,7 +357,7 @@ def apply(args, block)
353
357
354
358
private_constant :SuccessArray
355
359
356
- # @!visibility private
360
+ # @private
357
361
class Failed < CompletedWithResult
358
362
def initialize ( reason )
359
363
@Reason = reason
@@ -382,7 +386,7 @@ def apply(args, block)
382
386
383
387
private_constant :Failed
384
388
385
- # @!visibility private
389
+ # @private
386
390
class PartiallyFailed < CompletedWithResult
387
391
def initialize ( value , reason )
388
392
super ( )
@@ -421,6 +425,7 @@ def apply(args, block)
421
425
422
426
private_constant :InternalStates
423
427
428
+ # Common ancestor of {Event} and {Future} classes
424
429
class AbstractEventFuture < Synchronization ::Object
425
430
safe_initialization!
426
431
private ( *attr_atomic ( :internal_state ) - [ :internal_state ] )
@@ -1214,6 +1219,7 @@ def with_hidden_completable
1214
1219
end
1215
1220
1216
1221
# @abstract
1222
+ # @private
1217
1223
class AbstractPromise < Synchronization ::Object
1218
1224
safe_initialization!
1219
1225
include InternalStates
@@ -1278,16 +1284,20 @@ def initialize(default_executor)
1278
1284
super CompletableFuture . new ( self , default_executor )
1279
1285
end
1280
1286
1287
+ # @!visibility private
1281
1288
def succeed ( value , raise_on_reassign )
1282
1289
complete_with Success . new ( value ) , raise_on_reassign
1283
1290
end
1284
1291
1292
+ # @!visibility private
1285
1293
def fail ( reason , raise_on_reassign )
1286
1294
complete_with Failed . new ( reason ) , raise_on_reassign
1287
1295
end
1288
1296
1297
+ # @!visibility private
1289
1298
public :evaluate_to
1290
1299
1300
+ # @!visibility private
1291
1301
def evaluate_to! ( *args , block )
1292
1302
evaluate_to ( *args , block ) . wait!
1293
1303
end
@@ -1299,6 +1309,7 @@ class InnerPromise < AbstractPromise
1299
1309
1300
1310
# @abstract
1301
1311
class BlockedPromise < InnerPromise
1312
+ # @!visibility private
1302
1313
def self . new ( *args , &block )
1303
1314
promise = super ( *args , &block )
1304
1315
promise . blocked_by . each { |f | f . add_callback :callback_notify_blocked , promise }
@@ -1311,7 +1322,7 @@ def initialize(future, blocked_by_futures, countdown)
1311
1322
@Countdown = AtomicFixnum . new countdown
1312
1323
end
1313
1324
1314
- # @api private
1325
+ # @!visibility private
1315
1326
def on_done ( future )
1316
1327
countdown = process_on_done ( future )
1317
1328
completable = completable? ( countdown , future )
@@ -1324,6 +1335,7 @@ def on_done(future)
1324
1335
end
1325
1336
end
1326
1337
1338
+ # @!visibility private
1327
1339
def touch
1328
1340
# TODO (pitr-ch 13-Jun-2016): on construction pass down references of delays to be touched, avoids extra casses
1329
1341
blocked_by . each ( &:touch )
@@ -1335,6 +1347,7 @@ def blocked_by
1335
1347
@BlockedBy
1336
1348
end
1337
1349
1350
+ # @!visibility private
1338
1351
def inspect
1339
1352
"#{ to_s [ 0 ..-2 ] } blocked_by:[#{ blocked_by . map ( &:to_s ) . join ( ', ' ) } ]>"
1340
1353
end
@@ -1378,6 +1391,7 @@ def initialize(blocked_by_future, default_executor, executor, args, &task)
1378
1391
@Args = args
1379
1392
end
1380
1393
1394
+ # @!visibility private
1381
1395
def executor
1382
1396
@Executor
1383
1397
end
@@ -1579,6 +1593,8 @@ def initialize(event1, event2, default_executor)
1579
1593
super Event . new ( self , default_executor ) , [ event1 , event2 ] , 2
1580
1594
end
1581
1595
1596
+ private
1597
+
1582
1598
def on_completable ( done_future )
1583
1599
complete_with COMPLETED
1584
1600
end
@@ -1590,6 +1606,8 @@ def initialize(future, event, default_executor)
1590
1606
@FutureResult = future
1591
1607
end
1592
1608
1609
+ private
1610
+
1593
1611
def on_completable ( done_future )
1594
1612
complete_with @FutureResult . internal_state
1595
1613
end
@@ -1602,6 +1620,8 @@ def initialize(future1, future2, default_executor)
1602
1620
@Future2Result = future2
1603
1621
end
1604
1622
1623
+ private
1624
+
1605
1625
def on_completable ( done_future )
1606
1626
success1 , value1 , reason1 = @Future1Result . result
1607
1627
success2 , value2 , reason2 = @Future2Result . result
@@ -1620,6 +1640,8 @@ def initialize(event, default_executor)
1620
1640
super Event . new ( self , default_executor ) , [ event ] , 1
1621
1641
end
1622
1642
1643
+ private
1644
+
1623
1645
def on_completable ( done_future )
1624
1646
complete_with COMPLETED
1625
1647
end
@@ -1630,6 +1652,8 @@ def initialize(future, default_executor)
1630
1652
super Future . new ( self , default_executor ) , [ future ] , 1
1631
1653
end
1632
1654
1655
+ private
1656
+
1633
1657
def on_completable ( done_future )
1634
1658
complete_with done_future . internal_state
1635
1659
end
@@ -1684,6 +1708,7 @@ def on_completable(done_future)
1684
1708
1685
1709
# @abstract
1686
1710
class AbstractAnyPromise < BlockedPromise
1711
+ # @!visibility private
1687
1712
def touch
1688
1713
blocked_by . each ( &:touch ) unless @Future . completed?
1689
1714
end
@@ -1735,6 +1760,7 @@ def completable?(countdown, future)
1735
1760
end
1736
1761
1737
1762
class DelayPromise < InnerPromise
1763
+ # @!visibility private
1738
1764
def touch
1739
1765
@Future . complete_with COMPLETED
1740
1766
end
@@ -1747,10 +1773,12 @@ def initialize(default_executor)
1747
1773
end
1748
1774
1749
1775
class ScheduledPromise < InnerPromise
1776
+ # @!visibility private
1750
1777
def intended_time
1751
1778
@IntendedTime
1752
1779
end
1753
1780
1781
+ # @!visibility private
1754
1782
def inspect
1755
1783
"#{ to_s [ 0 ..-2 ] } intended_time:[#{ @IntendedTime } }>"
1756
1784
end
@@ -1816,6 +1844,7 @@ def initialize(default_executor, intended_time)
1816
1844
# TODO try stealing pool, each thread has it's own queue
1817
1845
1818
1846
### Experimental features follow
1847
+
1819
1848
module Concurrent
1820
1849
module Promises
1821
1850
module FactoryMethods
0 commit comments