@@ -394,19 +394,20 @@ public <T> T get(ScopedValue<T> key) {
394
394
* to its value in the current thread.
395
395
* When the operation completes (normally or with an exception), each scoped value
396
396
* in the mapping will revert to being unbound, or revert to its previous value
397
- * when previously bound, in the current thread.
397
+ * when previously bound, in the current thread. If {@code op} completes with an
398
+ * exception then it propagated by this method.
398
399
*
399
- * <p> Scoped values are intended to be used in a <em>structured manner</em>.
400
- * If {@code op} creates a {@link StructuredTaskScope} but does not {@linkplain
401
- * StructuredTaskScope#close() close} it, then exiting {@code op} causes the
402
- * underlying construct of each {@code StructuredTaskScope} created in the
403
- * dynamic scope to be closed. This may require blocking until all child threads
404
- * have completed their sub-tasks. The closing is done in the reverse order that
405
- * they were created. Once closed, {@link StructureViolationException} is thrown.
400
+ * <p> Scoped values are intended to be used in a <em>structured manner</em>. If code
401
+ * invoked directly or indirectly by the operation creates a {@link StructuredTaskScope}
402
+ * but does not {@linkplain StructuredTaskScope#close() close} it, then it is detected
403
+ * as a <em>structure violation</em> when the operation completes (normally or with an
404
+ * exception). In that case, the underlying construct of the {@code StructuredTaskScope}
405
+ * is closed and {@link StructureViolationException} is thrown.
406
406
*
407
407
* @param op the operation to run
408
408
* @param <R> the type of the result of the operation
409
409
* @return the result
410
+ * @throws StructureViolationException if a structure violation is detected
410
411
* @throws Exception if {@code op} completes with an exception
411
412
* @see ScopedValue#callWhere(ScopedValue, Object, Callable)
412
413
*/
@@ -423,19 +424,20 @@ public <R> R call(Callable<? extends R> op) throws Exception {
423
424
* to its value in the current thread.
424
425
* When the operation completes (normally or with an exception), each scoped value
425
426
* in the mapping will revert to being unbound, or revert to its previous value
426
- * when previously bound, in the current thread.
427
+ * when previously bound, in the current thread. If {@code op} completes with an
428
+ * exception then it propagated by this method.
427
429
*
428
- * <p> Scoped values are intended to be used in a <em>structured manner</em>.
429
- * If {@code op} creates a {@link StructuredTaskScope} but does not {@linkplain
430
- * StructuredTaskScope#close() close} it, then exiting {@code op} causes the
431
- * underlying construct of each {@code StructuredTaskScope} created in the
432
- * dynamic scope to be closed. This may require blocking until all child threads
433
- * have completed their sub-tasks. The closing is done in the reverse order that
434
- * they were created. Once closed, {@link StructureViolationException} is thrown.
430
+ * <p> Scoped values are intended to be used in a <em>structured manner</em>. If code
431
+ * invoked directly or indirectly by the operation creates a {@link StructuredTaskScope}
432
+ * but does not {@linkplain StructuredTaskScope#close() close} it, then it is detected
433
+ * as a <em>structure violation</em> when the operation completes (normally or with an
434
+ * exception). In that case, the underlying construct of the {@code StructuredTaskScope}
435
+ * is closed and {@link StructureViolationException} is thrown.
435
436
*
436
437
* @param op the operation to run
437
438
* @param <R> the type of the result of the operation
438
439
* @return the result
440
+ * @throws StructureViolationException if a structure violation is detected
439
441
* @see ScopedValue#getWhere(ScopedValue, Object, Supplier)
440
442
*/
441
443
public <R > R get (Supplier <? extends R > op ) {
@@ -486,17 +488,18 @@ private <R> R runWith(Snapshot newSnapshot, Callable<R> op) {
486
488
* in the current thread.
487
489
* When the operation completes (normally or with an exception), each scoped value
488
490
* in the mapping will revert to being unbound, or revert to its previous value
489
- * when previously bound, in the current thread.
491
+ * when previously bound, in the current thread. If {@code op} completes with an
492
+ * exception then it propagated by this method.
490
493
*
491
- * <p> Scoped values are intended to be used in a <em>structured manner</em>.
492
- * If {@code op} creates a {@link StructuredTaskScope} but does not {@linkplain
493
- * StructuredTaskScope#close() close} it, then exiting {@code op} causes the
494
- * underlying construct of each {@code StructuredTaskScope} created in the
495
- * dynamic scope to be closed. This may require blocking until all child threads
496
- * have completed their sub-tasks. The closing is done in the reverse order that
497
- * they were created. Once closed, {@link StructureViolationException} is thrown.
494
+ * <p> Scoped values are intended to be used in a <em>structured manner</em>. If code
495
+ * invoked directly or indirectly by the operation creates a {@link StructuredTaskScope}
496
+ * but does not {@linkplain StructuredTaskScope#close() close} it, then it is detected
497
+ * as a <em>structure violation</em> when the operation completes (normally or with an
498
+ * exception). In that case, the underlying construct of the {@code StructuredTaskScope}
499
+ * is closed and {@link StructureViolationException} is thrown.
498
500
*
499
501
* @param op the operation to run
502
+ * @throws StructureViolationException if a structure violation is detected
500
503
* @see ScopedValue#runWhere(ScopedValue, Object, Runnable)
501
504
*/
502
505
public void run (Runnable op ) {
@@ -553,15 +556,15 @@ public static <T> Carrier where(ScopedValue<T> key, T value) {
553
556
* Calls a value-returning operation with a {@code ScopedValue} bound to a value
554
557
* in the current thread. When the operation completes (normally or with an
555
558
* exception), the {@code ScopedValue} will revert to being unbound, or revert to
556
- * its previous value when previously bound, in the current thread.
559
+ * its previous value when previously bound, in the current thread. If {@code op}
560
+ * completes with an exception then it propagated by this method.
557
561
*
558
- * <p> Scoped values are intended to be used in a <em>structured manner</em>.
559
- * If {@code op} creates a {@link StructuredTaskScope} but does not {@linkplain
560
- * StructuredTaskScope#close() close} it, then exiting {@code op} causes the
561
- * underlying construct of each {@code StructuredTaskScope} created in the
562
- * dynamic scope to be closed. This may require blocking until all child threads
563
- * have completed their sub-tasks. The closing is done in the reverse order that
564
- * they were created. Once closed, {@link StructureViolationException} is thrown.
562
+ * <p> Scoped values are intended to be used in a <em>structured manner</em>. If code
563
+ * invoked directly or indirectly by the operation creates a {@link StructuredTaskScope}
564
+ * but does not {@linkplain StructuredTaskScope#close() close} it, then it is detected
565
+ * as a <em>structure violation</em> when the operation completes (normally or with an
566
+ * exception). In that case, the underlying construct of the {@code StructuredTaskScope}
567
+ * is closed and {@link StructureViolationException} is thrown.
565
568
*
566
569
* @implNote
567
570
* This method is implemented to be equivalent to:
@@ -576,6 +579,7 @@ public static <T> Carrier where(ScopedValue<T> key, T value) {
576
579
* @param <R> the result type
577
580
* @param op the operation to call
578
581
* @return the result
582
+ * @throws StructureViolationException if a structure violation is detected
579
583
* @throws Exception if the operation completes with an exception
580
584
*/
581
585
public static <T , R > R callWhere (ScopedValue <T > key ,
@@ -588,15 +592,15 @@ public static <T, R> R callWhere(ScopedValue<T> key,
588
592
* Invokes a supplier of results with a {@code ScopedValue} bound to a value
589
593
* in the current thread. When the operation completes (normally or with an
590
594
* exception), the {@code ScopedValue} will revert to being unbound, or revert to
591
- * its previous value when previously bound, in the current thread.
595
+ * its previous value when previously bound, in the current thread. If {@code op}
596
+ * completes with an exception then it propagated by this method.
592
597
*
593
- * <p> Scoped values are intended to be used in a <em>structured manner</em>.
594
- * If {@code op} creates a {@link StructuredTaskScope} but does not {@linkplain
595
- * StructuredTaskScope#close() close} it, then exiting {@code op} causes the
596
- * underlying construct of each {@code StructuredTaskScope} created in the
597
- * dynamic scope to be closed. This may require blocking until all child threads
598
- * have completed their sub-tasks. The closing is done in the reverse order that
599
- * they were created. Once closed, {@link StructureViolationException} is thrown.
598
+ * <p> Scoped values are intended to be used in a <em>structured manner</em>. If code
599
+ * invoked directly or indirectly by the operation creates a {@link StructuredTaskScope}
600
+ * but does not {@linkplain StructuredTaskScope#close() close} it, then it is detected
601
+ * as a <em>structure violation</em> when the operation completes (normally or with an
602
+ * exception). In that case, the underlying construct of the {@code StructuredTaskScope}
603
+ * is closed and {@link StructureViolationException} is thrown.
600
604
*
601
605
* @implNote
602
606
* This method is implemented to be equivalent to:
@@ -611,6 +615,7 @@ public static <T, R> R callWhere(ScopedValue<T> key,
611
615
* @param <R> the result type
612
616
* @param op the operation to call
613
617
* @return the result
618
+ * @throws StructureViolationException if a structure violation is detected
614
619
*/
615
620
public static <T , R > R getWhere (ScopedValue <T > key ,
616
621
T value ,
@@ -622,15 +627,15 @@ public static <T, R> R getWhere(ScopedValue<T> key,
622
627
* Run an operation with a {@code ScopedValue} bound to a value in the current
623
628
* thread. When the operation completes (normally or with an exception), the
624
629
* {@code ScopedValue} will revert to being unbound, or revert to its previous value
625
- * when previously bound, in the current thread.
630
+ * when previously bound, in the current thread. If {@code op} completes with an
631
+ * exception then it propagated by this method.
626
632
*
627
- * <p> Scoped values are intended to be used in a <em>structured manner</em>.
628
- * If {@code op} creates a {@link StructuredTaskScope} but does not {@linkplain
629
- * StructuredTaskScope#close() close} it, then exiting {@code op} causes the
630
- * underlying construct of each {@code StructuredTaskScope} created in the
631
- * dynamic scope to be closed. This may require blocking until all child threads
632
- * have completed their sub-tasks. The closing is done in the reverse order that
633
- * they were created. Once closed, {@link StructureViolationException} is thrown.
633
+ * <p> Scoped values are intended to be used in a <em>structured manner</em>. If code
634
+ * invoked directly or indirectly by the operation creates a {@link StructuredTaskScope}
635
+ * but does not {@linkplain StructuredTaskScope#close() close} it, then it is detected
636
+ * as a <em>structure violation</em> when the operation completes (normally or with an
637
+ * exception). In that case, the underlying construct of the {@code StructuredTaskScope}
638
+ * is closed and {@link StructureViolationException} is thrown.
634
639
*
635
640
* @implNote
636
641
* This method is implemented to be equivalent to:
@@ -643,6 +648,7 @@ public static <T, R> R getWhere(ScopedValue<T> key,
643
648
* @param value the value, can be {@code null}
644
649
* @param <T> the type of the value
645
650
* @param op the operation to call
651
+ * @throws StructureViolationException if a structure violation is detected
646
652
*/
647
653
public static <T > void runWhere (ScopedValue <T > key , T value , Runnable op ) {
648
654
where (key , value ).run (op );
0 commit comments