@@ -323,45 +323,6 @@ object Promise {
323
323
324
324
private val AlwaysUnit : Any => Unit = _ => ()
325
325
326
- sealed trait Responder [A ] { this : Future [A ] =>
327
- protected final def continueAll (wq : WaitQueue [A ]): Unit = {
328
- var ks = wq
329
- while (ks ne WaitQueue .Empty ) {
330
- continue(ks.first)
331
- ks = ks.rest
332
- }
333
- }
334
-
335
- protected def continue (k : K [A ]): Unit
336
-
337
- /**
338
- * Note: exceptions in responds are monitored. That is, if the
339
- * computation `k` throws a raw (ie. not encoded in a Future)
340
- * exception, it is handled by the current monitor, see
341
- * [[Monitor ]] for details.
342
- */
343
- def respond (k : Try [A ] => Unit ): Future [A ] = {
344
- continue(new Monitored (Local .save(), k))
345
- this
346
- }
347
-
348
- def transform [B ](f : Try [A ] => Future [B ]): Future [B ] = {
349
- val promise = interrupts[B ](this )
350
-
351
- continue(new FutureTransformer (Local .save(), f, promise))
352
-
353
- promise
354
- }
355
-
356
- protected def transformTry [B ](f : Try [A ] => Try [B ]): Future [B ] = {
357
- val promise = interrupts[B ](this )
358
-
359
- continue(new TryTransformer (Local .save(), f, promise))
360
-
361
- promise
362
- }
363
- }
364
-
365
326
// PUBLIC API
366
327
367
328
/**
@@ -465,9 +426,44 @@ object Promise {
465
426
* space leak is incurred from `flatMap` in the tail position since
466
427
* intermediate promises are merged into the root promise.
467
428
*/
468
- class Promise [A ] extends Future [A ] with Promise . Responder [ A ] with Updatable [Try [A ]] {
429
+ class Promise [A ] extends Future [A ] with Updatable [Try [A ]] {
469
430
import Promise ._
470
431
432
+ private final def continueAll (wq : WaitQueue [A ]): Unit = {
433
+ var ks = wq
434
+ while (ks ne WaitQueue .Empty ) {
435
+ continue(ks.first)
436
+ ks = ks.rest
437
+ }
438
+ }
439
+
440
+ /**
441
+ * Note: exceptions in responds are monitored. That is, if the
442
+ * computation `k` throws a raw (ie. not encoded in a Future)
443
+ * exception, it is handled by the current monitor, see
444
+ * [[Monitor ]] for details.
445
+ */
446
+ final def respond (k : Try [A ] => Unit ): Future [A ] = {
447
+ continue(new Monitored (Local .save(), k))
448
+ this
449
+ }
450
+
451
+ final def transform [B ](f : Try [A ] => Future [B ]): Future [B ] = {
452
+ val promise = interrupts[B ](this )
453
+
454
+ continue(new FutureTransformer (Local .save(), f, promise))
455
+
456
+ promise
457
+ }
458
+
459
+ final protected def transformTry [B ](f : Try [A ] => Try [B ]): Future [B ] = {
460
+ val promise = interrupts[B ](this )
461
+
462
+ continue(new TryTransformer (Local .save(), f, promise))
463
+
464
+ promise
465
+ }
466
+
471
467
// Note: this will always be one of:
472
468
// - WaitQueue (Waiting)
473
469
// - Interrupted
@@ -776,7 +772,7 @@ class Promise[A] extends Future[A] with Promise.Responder[A] with Updatable[Try[
776
772
*
777
773
* @throws Promise.ImmutableResult if the Promise is already populated
778
774
*/
779
- def update (result : Try [A ]): Unit = {
775
+ final def update (result : Try [A ]): Unit = {
780
776
updateIfEmpty(result) || {
781
777
val current = Await .result(liftToTry)
782
778
throw ImmutableResult (s " Result set multiple times. Value=' $current', New=' $result' " )
0 commit comments