A Callback to resume execution after another Deferred.
| 1340 | * A {@link Callback} to resume execution after another Deferred. |
| 1341 | */ |
| 1342 | private final class Continue implements Callback<Object, Object> { |
| 1343 | private final Deferred d; |
| 1344 | private final Callback cb; |
| 1345 | |
| 1346 | /** |
| 1347 | * Constructor. |
| 1348 | * @param d The other Deferred we need to resume after. |
| 1349 | * @param cb The callback that returned that Deferred or {@code null} if we |
| 1350 | * don't know where this Deferred comes from (it was our initial result). |
| 1351 | */ |
| 1352 | public Continue(final Deferred d, final Callback cb) { |
| 1353 | this.d = d; |
| 1354 | this.cb = cb; |
| 1355 | } |
| 1356 | |
| 1357 | public Object call(final Object arg) { |
| 1358 | if (arg instanceof Deferred) { |
| 1359 | handleContinuation((Deferred) arg, cb); |
| 1360 | } else if (!casState(PAUSED, RUNNING)) { |
| 1361 | final String cb2s = cb == null ? "null" : cb + "@" + cb.hashCode(); |
| 1362 | throw new AssertionError("Tried to resume the execution of " |
| 1363 | + Deferred.this + ") although it's not in state=PAUSED." |
| 1364 | + " This occurred after the completion of " + d |
| 1365 | + " which was originally returned by callback=" + cb2s); |
| 1366 | } |
| 1367 | result = arg; |
| 1368 | runCallbacks(); |
| 1369 | return arg; |
| 1370 | } |
| 1371 | |
| 1372 | public String toString() { |
| 1373 | return "(continuation of Deferred@" + Deferred.super.hashCode() |
| 1374 | + " after " + (cb != null ? cb + "@" + cb.hashCode() : d) + ')'; |
| 1375 | } |
| 1376 | }; |
| 1377 | |
| 1378 | /** |
| 1379 | * Returns a helpful string representation of this {@code Deferred}. |
nothing calls this directly
no outgoing calls
no test coverage detected