(final Future<T> result)
| 235 | } |
| 236 | |
| 237 | @SuppressWarnings("unchecked") |
| 238 | public final boolean trySetState(final Future<T> result) { |
| 239 | try { |
| 240 | while (true) { |
| 241 | final Object curr = state; |
| 242 | if (curr instanceof SatisfiedFuture) |
| 243 | return false; |
| 244 | else if (curr instanceof Promise && !(curr instanceof Continuation)) |
| 245 | return ((Promise<T>) curr).becomeIfEmpty(result); |
| 246 | else if (curr instanceof LinkedContinuation) |
| 247 | return ((LinkedContinuation<?, T>) curr).becomeIfEmpty(result); |
| 248 | else if (result instanceof Promise) { |
| 249 | ((Promise<T>) result).compress().link(this); |
| 250 | return true; |
| 251 | } else if (cas(curr, result)) { |
| 252 | if (curr != null) |
| 253 | ((WaitQueue<T>) curr).flush(result); |
| 254 | return true; |
| 255 | } |
| 256 | } |
| 257 | } catch (final StackOverflowError ex) { |
| 258 | if (!(this instanceof Continuation)) |
| 259 | LOGGER.log(Level.SEVERE, |
| 260 | "FATAL: Stack overflow when satisfying promise, the promise and its continuations won't be satisfied. " |
| 261 | + "Use `Future.tailrec` or increase the stack size (-Xss) if the future isn't recursive.", |
| 262 | ex); |
| 263 | throw ex; |
| 264 | } |
| 265 | } |
| 266 | |
| 267 | @SuppressWarnings("unchecked") |
| 268 | protected final WaitQueue<T> safeFlush(final Future<T> result) { |
no test coverage detected