|
66 | 66 | accept-either accept-either-async
|
67 | 67 | run-after-either run-after-either-async
|
68 | 68 |
|
69 |
| - then-compose then-compose-async) |
| 69 | + then-compose then-compose-async |
| 70 | + |
| 71 | + then-handle then-handle-async) |
70 | 72 |
|
71 | 73 | ;; The potemkin abstract type for
|
72 | 74 | ;; implementations such as CompletionStage
|
|
121 | 123 | (applyToEitherAsync [this other operator executor]
|
122 | 124 | (apply-to-either-async this other operator executor))
|
123 | 125 |
|
124 |
| - |
125 | 126 | (acceptEither [this other operator]
|
126 | 127 | (accept-either this other operator))
|
127 | 128 | (acceptEitherAsync [this other operator]
|
|
141 | 142 | (thenComposeAsync [this operator]
|
142 | 143 | (then-compose-async this operator))
|
143 | 144 | (thenComposeAsync [this operator executor]
|
144 |
| - (then-compose-async this operator executor))) |
| 145 | + (then-compose-async this operator executor)) |
| 146 | + |
| 147 | + (handle [this operator] |
| 148 | + (then-handle this operator)) |
| 149 | + (handleAsync [this operator] |
| 150 | + (then-handle-async this operator)) |
| 151 | + (handleAsync [this operator executor] |
| 152 | + (then-handle-async this operator executor))) |
145 | 153 |
|
146 | 154 | (definline realized?
|
147 | 155 | "Returns true if the manifold deferred is realized."
|
|
1529 | 1537 |
|
1530 | 1538 | (def ^:private then-apply-async (async-for then-apply))
|
1531 | 1539 |
|
| 1540 | + |
1532 | 1541 | (defn- then-accept [this ^Consumer operator]
|
1533 | 1542 | (assert-some operator)
|
1534 | 1543 | (chain this #(.accept operator %)))
|
1535 | 1544 |
|
1536 | 1545 | (def ^:private then-accept-async (async-for then-accept))
|
1537 | 1546 |
|
| 1547 | + |
1538 | 1548 | (defn- then-run [this ^Runnable operator]
|
1539 | 1549 | (assert-some operator)
|
1540 | 1550 | (chain this (fn [_] (.run operator))))
|
1541 | 1551 |
|
1542 | 1552 | (def ^:private then-run-async (async-for then-run))
|
1543 | 1553 |
|
| 1554 | + |
1544 | 1555 | (defn- then-combine [this other ^BiFunction operator]
|
1545 | 1556 | (assert-some other operator)
|
1546 | 1557 | (let-flow [mine this
|
|
1549 | 1560 |
|
1550 | 1561 | (def ^:private then-combine-async (async-for-dual then-combine))
|
1551 | 1562 |
|
| 1563 | + |
1552 | 1564 | (defn- then-accept-both [this other ^BiConsumer operator]
|
1553 | 1565 | (assert-some other operator)
|
1554 | 1566 | (let-flow [mine this
|
|
1557 | 1569 |
|
1558 | 1570 | (def ^:private then-accept-both-async (async-for-dual then-accept-both))
|
1559 | 1571 |
|
| 1572 | + |
1560 | 1573 | (defn- run-after-both [this other ^Runnable operator]
|
1561 | 1574 | (assert-some other operator)
|
1562 | 1575 | (let-flow [_ this
|
|
1566 | 1579 |
|
1567 | 1580 | (def ^:private run-after-both-async (async-for-dual run-after-both))
|
1568 | 1581 |
|
| 1582 | + |
1569 | 1583 | (defn- apply-to-either [this other ^java.util.function.Function operator]
|
1570 | 1584 | (assert-some other operator)
|
1571 | 1585 | (then-apply (alt this other) operator))
|
1572 | 1586 |
|
1573 | 1587 | (def ^:private apply-to-either-async (async-for-dual apply-to-either))
|
1574 | 1588 |
|
| 1589 | + |
1575 | 1590 | (defn- accept-either [this other ^java.util.function.Function operator]
|
1576 | 1591 | (assert-some other operator)
|
1577 | 1592 | (then-accept (alt this other) operator))
|
1578 | 1593 |
|
1579 | 1594 | (def ^:private accept-either-async (async-for-dual accept-either))
|
1580 | 1595 |
|
| 1596 | + |
1581 | 1597 | (defn- run-after-either [this other ^java.util.function.Function operator]
|
1582 | 1598 | (assert-some other operator)
|
1583 | 1599 | (then-run (alt this other) operator))
|
1584 | 1600 |
|
1585 | 1601 | (def ^:private run-after-either-async (async-for-dual run-after-either))
|
1586 | 1602 |
|
| 1603 | + |
1587 | 1604 | (defn- then-compose [this ^java.util.function.Function operator]
|
1588 | 1605 | (assert-some operator)
|
1589 | 1606 | (chain this (fn [value] (.apply operator value))))
|
1590 | 1607 |
|
1591 | 1608 | (def ^:private then-compose-async (async-for then-compose))
|
1592 | 1609 |
|
1593 | 1610 |
|
| 1611 | +(defn- then-handle [this ^java.util.function.BiFunction operator] |
| 1612 | + (assert-some operator) |
| 1613 | + (-> this |
| 1614 | + (chain #(.apply operator % nil)) |
| 1615 | + (catch #(.apply operator nil %)))) |
| 1616 | + |
| 1617 | +(def ^:private then-handle-async (async-for then-handle)) |
| 1618 | + |
| 1619 | + |
1594 | 1620 |
|
1595 | 1621 |
|
1596 | 1622 | ;;;
|
|
0 commit comments