Top Description Inners Fields Constructors Methods
org.eclipse.jetty.util

public Class SharedBlockingCallback

extends Object
Class Inheritance
Annotations
@Deprecated
Imports
java.io.Closeable, .IOException, .InterruptedIOException, java.util.Objects, java.util.concurrent.CancellationException, .TimeoutException, java.util.concurrent.locks.Condition, .ReentrantLock, org.slf4j.Logger, .LoggerFactory

Deprecated

Use org.eclipse.jetty.util.Blocker.Shared#callback()

Provides a reusable Callback that can block the thread while waiting to be completed.

A typical usage pattern is:

void someBlockingCall(Object... args) throws IOException
{
    try(Blocker blocker = sharedBlockingCallback.acquire())
    {
        someAsyncCall(args, blocker);
        blocker.block();
    }
}

Nested and Inner Type Summary

Modifier and TypeClass and Description
public class
SharedBlockingCallback.Blocker

A Closeable Callback.

private static class
private static class

Field Summary

Modifier and TypeField and Description
private SharedBlockingCallback.Blocker
private final Condition
private final Condition
private final ReentrantLock
private static final Throwable
private static final Throwable
private static final Logger
private static final Throwable

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public SharedBlockingCallback.Blocker
public boolean
fail(Throwable cause)

protected void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_blockerback to summary
private SharedBlockingCallback.Blocker _blocker
_completeback to summary
private final Condition _complete
_idleback to summary
private final Condition _idle
_lockback to summary
private final ReentrantLock _lock
FAILEDback to summary
private static final Throwable FAILED
IDLEback to summary
private static final Throwable IDLE
LOGback to summary
private static final Logger LOG
SUCCEEDEDback to summary
private static final Throwable SUCCEEDED

Constructor Detail

SharedBlockingCallbackback to summary
public SharedBlockingCallback()

Method Detail

acquireback to summary
public SharedBlockingCallback.Blocker acquire() throws IOException
failback to summary
public boolean fail(Throwable cause)
notCompleteback to summary
protected void notComplete(SharedBlockingCallback.Blocker blocker)
org.eclipse.jetty.util back to summary

public Class SharedBlockingCallback.Blocker

extends Object
implements Callback, Closeable, Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable, java.io.Closeable, java.lang.AutoCloseable, org.eclipse.jetty.util.Callback, org.eclipse.jetty.util.thread.Invocable

A Closeable Callback. Uses the auto close mechanism to check block has been called OK.

Implements Callback because calls to this callback do not blocak, rather they wakeup the thread that is blocked in block()

Field Summary

Modifier and TypeField and Description
private Throwable

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public void
block()

Block until the Callback has succeeded or failed and after the return leave in the state to allow reuse.

public void
close()

Implements java.io.Closeable.close.

Check the Callback has succeeded or failed and after the return leave in the state to allow reuse.

public void
failed(Throwable
the reason for the operation failure
cause
)

Overrides default org.eclipse.jetty.util.Callback.failed.

Callback invoked when the operation fails.

public Invocable.InvocationType
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.

public void
succeeded()

Overrides default org.eclipse.jetty.util.Callback.succeeded.

Callback invoked when the operation completes.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

_stateback to summary
private Throwable _state

Constructor Detail

Blockerback to summary
protected Blocker()

Method Detail

blockback to summary
public void block() throws IOException

Block until the Callback has succeeded or failed and after the return leave in the state to allow reuse. This is useful for code that wants to repeatable use a FutureCallback to convert an asynchronous API to a blocking API.

Exceptions
IOException:
if exception was caught during blocking, or callback was cancelled
closeback to summary
public void close()

Implements java.io.Closeable.close.

Check the Callback has succeeded or failed and after the return leave in the state to allow reuse.

Annotations
@Override
failedback to summary
public void failed(Throwable cause)

Overrides default org.eclipse.jetty.util.Callback.failed.

Doc from org.eclipse.jetty.util.Callback.failed.

Callback invoked when the operation fails.

Parameters
cause:Throwable

the reason for the operation failure

Annotations
@Override
getInvocationTypeback to summary
public Invocable.InvocationType getInvocationType()

Overrides default org.eclipse.jetty.util.thread.Invocable.getInvocationType.

Returns:Invocable.InvocationType

Doc from org.eclipse.jetty.util.thread.Invocable.getInvocationType.

The InvocationType of this object

Annotations
@Override
runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@Override
succeededback to summary
public void succeeded()

Overrides default org.eclipse.jetty.util.Callback.succeeded.

Doc from org.eclipse.jetty.util.Callback.succeeded.

Callback invoked when the operation completes.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
org.eclipse.jetty.util back to summary

private Class SharedBlockingCallback.BlockerFailedException

extends Exception
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Constructor Detail

BlockerFailedExceptionback to summary
public BlockerFailedException(Throwable cause)
org.eclipse.jetty.util back to summary

private Class SharedBlockingCallback.BlockerTimeoutException

extends TimeoutException
Class Inheritance

Constructor Summary

AccessConstructor and Description
private

Constructor Detail

BlockerTimeoutExceptionback to summary
private BlockerTimeoutException()