use of com.generallycloud.baseio.concurrent.Waiter in project baseio by generallycloud.
the class HttpClient method request.
public synchronized HttpFuture request(HttpFuture future, long timeout) throws IOException {
Waiter waiter = ioEventHandle.newWaiter();
session.flush(future);
if (waiter.await(timeout)) {
throw new TimeoutException("timeout");
}
return (HttpFuture) waiter.getResponse();
}
use of com.generallycloud.baseio.concurrent.Waiter in project baseio by generallycloud.
the class HttpIOEventHandle method accept.
@Override
public void accept(SocketSession session, Future future) throws Exception {
HttpFuture f = (HttpFuture) future;
Waiter waiter = this.waiter;
if (waiter != null) {
this.waiter = null;
waiter.response(f);
}
}
use of com.generallycloud.baseio.concurrent.Waiter in project baseio by generallycloud.
the class AbstractSocketChannelConnector method initService.
@Override
protected void initService(ServerConfiguration configuration) throws IOException {
String SERVER_HOST = configuration.getSERVER_HOST();
int SERVER_PORT = configuration.getSERVER_PORT();
this.waiter = new Waiter();
this.serverAddress = new InetSocketAddress(SERVER_HOST, SERVER_PORT);
this.connect(getServerSocketAddress());
}
use of com.generallycloud.baseio.concurrent.Waiter in project baseio by generallycloud.
the class RedisClient method sendCommand.
private synchronized RedisNode sendCommand(byte[] command, byte[]... args) throws IOException {
RedisFuture future = new RedisCmdFuture(context);
future.writeCommand(command, args);
Waiter waiter = ioEventHandle.newWaiter();
session.flush(future);
if (waiter.await(timeout)) {
throw new TimeoutException("timeout");
}
return (RedisNode) waiter.getResponse();
}
use of com.generallycloud.baseio.concurrent.Waiter in project baseio by generallycloud.
the class RedisIOEventHandle method accept.
@Override
public void accept(SocketSession session, Future future) throws Exception {
RedisFuture f = (RedisFuture) future;
Waiter waiter = this.waiter;
if (waiter != null) {
this.waiter = null;
waiter.response(f);
}
}
Aggregations