orc.orchard
Interface Waiter

All Known Implementing Classes:
ThreadWaiter

public interface Waiter

Provides blocking or callback behavior for asynchronous methods.

In a servlet, it's bad practice to actually block a method call because threads are a limited resource. As an alternative, some servlet containers allow you to register a request to be suspended and later resumed/retried (examples: Jetty Continuations, Java Servlet 3.0 suspendable requests).

This interface abstracts away the differences between blocking and callback implementations of asynchrony so the underlying implementation doesn't have to know about them.

This is not thread-safe -- you are expected to call it from within a block synchronized on the monitor.

Author:
quark

Method Summary
 void resume()
          Signal that the asynchronous call should be resumed.
 void suspend(java.lang.Object monitor)
          Suspend the current request and release locks.
 

Method Detail

suspend

void suspend(java.lang.Object monitor)
             throws java.lang.InterruptedException
Suspend the current request and release locks. When the request is resumed, any of the following may happen: Therefore the request must be reentrant.

Parameters:
monitor - the monitor to wait on if a blocking implementation is used.
Throws:
java.lang.InterruptedException - if the call timed out.

resume

void resume()
Signal that the asynchronous call should be resumed. This may mean that a waiting call to suspend() returns, or that the asynchronous call is simply retried.