blob: 150755eb3fac07b72d6e9fedb4e765aa8b3a2c48 [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.
Madan Jampaniab6d3112014-10-02 16:30:14 -070010 */
Madan Jampani53e44e62014-10-07 12:39:51 -070011public interface Response {
Madan Jampaniab6d3112014-10-02 16:30:14 -070012
13 /**
14 * Gets the response waiting for a designated timeout period.
15 * @param timeout timeout period (since request was sent out)
16 * @param tu unit of time.
Madan Jampani53e44e62014-10-07 12:39:51 -070017 * @return response payload
Madan Jampaniab6d3112014-10-02 16:30:14 -070018 * @throws TimeoutException if the timeout expires before the response arrives.
19 */
Madan Jampani53e44e62014-10-07 12:39:51 -070020 public byte[] get(long timeout, TimeUnit tu) throws TimeoutException;
Madan Jampaniab6d3112014-10-02 16:30:14 -070021
22 /**
23 * Gets the response waiting for indefinite timeout period.
Madan Jampani53e44e62014-10-07 12:39:51 -070024 * @return response payload
Madan Jampaniab6d3112014-10-02 16:30:14 -070025 * @throws InterruptedException if the thread is interrupted before the response arrives.
26 */
Madan Jampani53e44e62014-10-07 12:39:51 -070027 public byte[] get() throws InterruptedException;
Madan Jampaniab6d3112014-10-02 16:30:14 -070028
29 /**
30 * Checks if the response is ready without blocking.
31 * @return true if response is ready, false otherwise.
32 */
33 public boolean isReady();
34}