Search in sources :

Example 1 with CancelableUnitOfWork

use of org.eclipse.xtext.util.concurrent.CancelableUnitOfWork in project xtext-core by eclipse.

the class OutdatedStateManager method exec.

public <R extends Object, P extends Resource> R exec(final IUnitOfWork<R, P> work, final P param) {
    try {
        R _xblockexpression = null;
        {
            final Boolean wasCancelationAllowed = this.cancelationAllowed.get();
            R _xtrycatchfinallyexpression = null;
            try {
                R _xblockexpression_1 = null;
                {
                    if ((work instanceof CancelableUnitOfWork<?, ?>)) {
                        CancelIndicator _xifexpression = null;
                        if ((param == null)) {
                            final CancelIndicator _function = () -> {
                                return true;
                            };
                            _xifexpression = _function;
                        } else {
                            _xifexpression = this.newCancelIndicator(param.getResourceSet());
                        }
                        ((CancelableUnitOfWork<?, ?>) work).setCancelIndicator(_xifexpression);
                    } else {
                        this.cancelationAllowed.set(Boolean.valueOf(false));
                    }
                    _xblockexpression_1 = work.exec(param);
                }
                _xtrycatchfinallyexpression = _xblockexpression_1;
            } finally {
                this.cancelationAllowed.set(wasCancelationAllowed);
            }
            _xblockexpression = _xtrycatchfinallyexpression;
        }
        return _xblockexpression;
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : CancelableUnitOfWork(org.eclipse.xtext.util.concurrent.CancelableUnitOfWork) CancelIndicator(org.eclipse.xtext.util.CancelIndicator)

Aggregations

CancelIndicator (org.eclipse.xtext.util.CancelIndicator)1 CancelableUnitOfWork (org.eclipse.xtext.util.concurrent.CancelableUnitOfWork)1