@@ -21,49 +21,50 @@ private inline def check[A](inline code: A): A =
2121@ throws[InterruptedException ]
2222inline def interruptibly [A ](inline code : A ): A = check(code)
2323
24- extension [I , O ](f : I => O )
25- /** @define text1
26- * Makes a function responsive to interrupts: `f.interruptibly` has the same behavior as `f`
27- * except that it checks for interrupts before each invocation. Additionally,
28- * `f.interruptibly` checks for interrupts once, before the resulting function is used.
29- *
30- * @note
31- * This is only implemented for functions of arity 1 and 2. For higher arities, one can use
32- * `untupled(f.tupled.interruptibly)`.
33- *
34- * @since 1.5
35- *
36- * $text1
37- */
38- @ throws[InterruptedException ]
39- def interruptibly : I => O = check(x => check(f(x)))
24+ given InterruptiblyExtensions : AnyRef with
25+ extension [I , O ](f : I => O )
26+ /** @define text1
27+ * Makes a function responsive to interrupts: `f.interruptibly` has the same behavior as
28+ * `f` except that it checks for interrupts before each invocation. Additionally,
29+ * `f.interruptibly` checks for interrupts once, before the resulting function is used.
30+ *
31+ * @note
32+ * This is only implemented for functions of arity 1 and 2. For higher arities, one can use
33+ * `untupled(f.tupled.interruptibly)`.
34+ *
35+ * @since 1.5
36+ *
37+ * $text1
38+ */
39+ @ throws[InterruptedException ]
40+ def interruptibly : I => O = check(x => check(f(x)))
4041
41- extension [I1 , I2 , O ](f : (I1 , I2 ) => O )
42- /** $text1 */
43- @ throws[InterruptedException ]
44- def interruptibly : (I1 , I2 ) => O = check((x, y) => check(f(x, y)))
42+ extension [I1 , I2 , O ](f : (I1 , I2 ) => O )
43+ /** $text1 */
44+ @ throws[InterruptedException ]
45+ def interruptibly : (I1 , I2 ) => O = check((x, y) => check(f(x, y)))
4546
46- extension [I , O1 , O2 ](h : (I => O1 ) => O2 )
47- /** @define text2
48- * Makes the function argument of a higher-order function `h` responsive to interrupts:
49- * `h.interruptiby(f)` is equivalent to `h(f.interruptibly)` but is more convenient when `f`
50- * is defined as a lambda expression, e.g.: `list.forall.interruptibly(x => x > 0)`.
51- *
52- * @note
53- * This handling of higher-order functions only works with arguments `f` or arity 1 and
54- * 2. If `f` is a 3-argument function, for instance, `h.interruptibly(f)` is equivalent to
55- * `interruptibly(h(f))` instead. To achieved the desired behavior, one can use
56- * `h(untupled(f.tupled.interruptibly))`.
57- *
58- * @since 1.5
59- *
60- * $text2
61- */
62- @ throws[InterruptedException ]
63- def interruptibly ( using DummyImplicit ) : (I => O1 ) => O2 = f => h(f.interruptibly)
47+ extension [I , O1 , O2 ](h : (I => O1 ) => O2 )( using DummyImplicit )
48+ /** @define text2
49+ * Makes the function argument of a higher-order function `h` responsive to interrupts:
50+ * `h.interruptiby(f)` is equivalent to `h(f.interruptibly)` but is more convenient when
51+ * `f` is defined as a lambda expression, e.g.: `list.forall.interruptibly(x => x > 0)`.
52+ *
53+ * @note
54+ * This handling of higher-order functions only works with arguments `f` or arity 1 and
55+ * 2. If `f` is a 3-argument function, for instance, `h.interruptibly(f)` is equivalent to
56+ * `interruptibly(h(f))` instead. To achieved the desired behavior, one can use
57+ * `h(untupled(f.tupled.interruptibly))`.
58+ *
59+ * @since 1.5
60+ *
61+ * $text2
62+ */
63+ @ throws[InterruptedException ]
64+ def interruptibly : (I => O1 ) => O2 = f => h(f.interruptibly)
6465
65- extension [I1 , I2 , O1 , O2 ](h : ((I1 , I2 ) => O1 ) => O2 )
66- /** $text2 */
67- @ throws[InterruptedException ]
68- def interruptibly ( using d1 : DummyImplicit , d2 : DummyImplicit ) : ((I1 , I2 ) => O1 ) => O2 =
69- f => h(f.interruptibly)
66+ extension [I1 , I2 , O1 , O2 ](h : ((I1 , I2 ) => O1 ) => O2 )( using d1 : DummyImplicit , d2 : DummyImplicit )
67+ /** $text2 */
68+ @ throws[InterruptedException ]
69+ def interruptibly : ((I1 , I2 ) => O1 ) => O2 =
70+ f => h(f.interruptibly)
0 commit comments