org.eclipse.wst.jsdt.chromium.util

## Class AsyncFuture.SyncOperation<RES>

- java.lang.Object
- - org.eclipse.wst.jsdt.chromium.util.AsyncFuture.SyncOperation<RES>

Enclosing class:
  AsyncFuture<T>

    public abstract static class AsyncFuture.SyncOperation<RES>
    extends java.lang.Object

Helper class that presents operation meant to be executed synchronously in the current thread as an asynchronous `AsyncFuture.Operation` suitable for `AsyncFuture`. User implements `runSync()` method and passes the object returned form `asAsyncOperation()` to `AsyncFuture`. Immediately after this he must call `execute()` method (because some threads may have already got blocked on `AsyncFuture.getSync()` method). However the user `runSync()` method may not be actually called if `AsyncFuture` didn't started the operation for some reason.

### Constructor Summary

Constructors
Constructor and Description
`SyncOperation()`

### Method Summary

All Methods Instance Methods Abstract Methods Concrete Methods
`AsyncFuture.Operation<RES>` `asAsyncOperation()`
`void` `execute()` User must call this method immediately after he passed the object to `AsyncFuture`.
`protected abstract RES` `runSync()` Does whatever tasks the operation requires.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### SyncOperation

    public SyncOperation()

### Method Detail

#### execute

    public void execute()
                 throws MethodIsBlockingException

User must call this method immediately after he passed the object to `AsyncFuture`. Failure to do this may cause that some threads remain blocked waiting for result.

Throws:
  `MethodIsBlockingException` - as the `runSync()` is blocking

#### asAsyncOperation

    public AsyncFuture.Operation<RES> asAsyncOperation()

Returns:
  Operation<RES> type suitable for `AsyncFuture.initializeReference(java.util.concurrent.atomic.AtomicReference<org.eclipse.wst.jsdt.chromium.util.AsyncFuture<T>>, org.eclipse.wst.jsdt.chromium.util.AsyncFuture.Operation<T>)` and `AsyncFuture.reinitializeReference(java.util.concurrent.atomic.AtomicReference<org.eclipse.wst.jsdt.chromium.util.AsyncFuture<T>>, org.eclipse.wst.jsdt.chromium.util.AsyncFuture.Operation<T>)` methods.

#### runSync

    protected abstract RES runSync()
                            throws MethodIsBlockingException

Does whatever tasks the operation requires. It may also fail with no special precautions.

Throws:
  `MethodIsBlockingException` - method may deal with blocking operations