blob: 04675ce28df23659330ebbdf209639411079a20e [file] [log] [blame]
Madan Jampaniab6d3112014-10-02 16:30:14 -07001package org.onlab.netty;
2
3import java.util.concurrent.TimeUnit;
4import java.util.concurrent.TimeoutException;
5
6/**
7 * Response object returned when making synchronous requests.
8 * Can you used to check is a response is ready and/or wait for a response
9 * to become available.
10 *
11 * @param <T> type of response.
12 */
13public interface Response<T> {
14
15 /**
16 * Gets the response waiting for a designated timeout period.
17 * @param timeout timeout period (since request was sent out)
18 * @param tu unit of time.
19 * @return response
20 * @throws TimeoutException if the timeout expires before the response arrives.
21 */
22 public T get(long timeout, TimeUnit tu) throws TimeoutException;
23
24 /**
25 * Gets the response waiting for indefinite timeout period.
26 * @return response
27 * @throws InterruptedException if the thread is interrupted before the response arrives.
28 */
29 public T get() throws InterruptedException;
30
31 /**
32 * Checks if the response is ready without blocking.
33 * @return true if response is ready, false otherwise.
34 */
35 public boolean isReady();
36}