MCPcopy Create free account
hub / github.com/traneio/future / link

Method link

future-java/src/main/java/io/trane/future/Promise.java:285–305  ·  view source on GitHub ↗
(final Promise<T> target)

Source from the content-addressed store, hash-verified

283 }
284
285 @SuppressWarnings("unchecked")
286 private final void link(final Promise<T> target) {
287 while (true) {
288 final Object curr = state;
289 if (curr instanceof SatisfiedFuture) {
290 target.become((SatisfiedFuture<T>) curr);
291 return;
292 } else {
293 Object newState;
294 if (target instanceof Continuation)
295 newState = new LinkedContinuation<>((Continuation<T, ?>) target);
296 else
297 newState = target;
298 if (cas(curr, newState)) {
299 if (curr != null)
300 ((WaitQueue<T>) curr).forward(target);
301 return;
302 }
303 }
304 }
305 }
306
307 @SuppressWarnings("unchecked")
308 protected final <R> Future<R> continuation(final Continuation<T, R> c) {

Callers 2

trySetStateMethod · 0.80
safeFlushMethod · 0.80

Calls 3

casMethod · 0.95
becomeMethod · 0.80
forwardMethod · 0.65

Tested by

no test coverage detected