Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  * Copyright 2012-2015, Inc. or its affiliates. All Rights Reserved.
  * Licensed under the Apache License, Version 2.0 (the "License"). You may not
  * use this file except in compliance with the License. A copy of the License is
  * located at
 * or in the "license" file accompanying this file. This file is distributed on
 * express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
Interface between synchronous and asynchronous code. Serves as a root scope for asynchronous computation and as event loop for the owning synchronous code.

public abstract class AsyncScope extends AsyncContextAware implements Cancelable {
    private final AsyncScopeContext context;
    public AsyncScope() {
        // The reason this(...) is not called is to keep the same stack depth for both constructors.
        // It simplifies creation of async stack traces
        this. = new AsyncScopeContext(thisfalsefalse);
    public AsyncScope(boolean disableAsyncStackTraceboolean excludeAsyncScopeStack) {
        this. = new AsyncScopeContext(thisdisableAsyncStackTraceexcludeAsyncScopeStack);
    public void cancel(Throwable cause) {
    public boolean isCancelRequested() {
        return .isCancelRequested();
        return .getAsynchronousStackTraceDump();

Execute all queued tasks. If execution of those tasks result in addition of new tasks to the queue execute them as well.

Unless there are external dependencies or bugs single call to this method performs the complete asynchronous execution.

In presence of external dependencies it is expected that eventLoop() is called every time after change in their state can unblock the asynchronous execution.

true means there are no tasks originated from this scope that are not done yet.
    public boolean eventLoop() throws Throwable {
        return .eventLoop();
    public boolean isComplete() {
        return .isComplete();
    public Throwable getFailure() {
        return .getFailure();
        return .getRootContext();
    protected abstract void doAsync() throws Throwable;
New to GrepCode? Check out our FAQ X