use of com.generallycloud.baseio.protocol.ChannelFuture in project baseio by generallycloud.
the class AioSocketSessionManager method broadcast.
@Override
public void broadcast(Future future) throws IOException {
if (getManagedSessionSize() == 0) {
return;
}
SocketChannel channel = context.getSimulateSocketChannel();
ChannelFuture f = (ChannelFuture) future;
context.getProtocolEncoder().encode(channel, f);
broadcastChannelFuture(f);
}
use of com.generallycloud.baseio.protocol.ChannelFuture in project baseio by generallycloud.
the class AbstractSocketChannel method releaseFutures.
protected void releaseFutures() {
ReleaseUtil.release(readFuture);
ReleaseUtil.release(sslReadFuture);
ClosedChannelException e = null;
if (writeFuture != null && !writeFuture.isReleased()) {
e = new ClosedChannelException(session.toString());
onFutureException(writeFuture, e);
}
LinkedQueue<ChannelFuture> writeFutures = this.writeFutures;
if (writeFutures.size() == 0) {
return;
}
ChannelFuture f = writeFutures.poll();
UnsafeSocketSession session = this.session;
if (e == null) {
e = new ClosedChannelException(session.toString());
}
for (; f != null; ) {
onFutureException(f, e);
ReleaseUtil.release(f);
f = writeFutures.poll();
}
}
use of com.generallycloud.baseio.protocol.ChannelFuture in project baseio by generallycloud.
the class NioGlobalSocketSessionManager method broadcast.
@Override
public void broadcast(Future future) throws IOException {
if (getManagedSessionSize() == 0) {
return;
}
SocketChannel channel = context.getSimulateSocketChannel();
ChannelFuture f = (ChannelFuture) future;
context.getProtocolEncoder().encode(channel, f);
broadcastChannelFuture(f);
}
use of com.generallycloud.baseio.protocol.ChannelFuture in project baseio by generallycloud.
the class NioSocketChannel method flush.
protected void flush(SocketSelectorEventLoop selectorLoop) throws IOException {
ChannelFuture f = writeFuture;
if (f == null) {
f = writeFutures.poll();
}
if (f == null) {
return;
}
for (; ; ) {
try {
f.write(this);
} catch (Throwable e) {
writeFuture = null;
ReleaseUtil.release(f);
throw e;
}
if (!f.isWriteCompleted()) {
writeFuture = f;
interestWrite(selectionKey);
return;
}
writeFutureLength(-f.getByteBufLimit());
ReleaseUtil.release(f);
f = writeFutures.poll();
if (f == null) {
break;
}
}
interestRead(selectionKey);
writeFuture = null;
}
use of com.generallycloud.baseio.protocol.ChannelFuture in project baseio by generallycloud.
the class TransparentByteBufReader method accept.
@Override
public void accept(SocketChannel channel, ByteBuf buffer) throws Exception {
for (; ; ) {
if (!buffer.hasRemaining()) {
return;
}
ChannelFuture future = channel.getReadFuture();
boolean setFutureNull = true;
if (future == null) {
future = channel.getProtocolDecoder().decode(channel, buffer);
setFutureNull = false;
}
try {
if (!future.read(channel, buffer)) {
if (!setFutureNull) {
channel.setReadFuture(future);
}
return;
}
} catch (Throwable e) {
ReleaseUtil.release(future);
if (e instanceof IOException) {
throw (IOException) e;
}
throw new IOException("exception occurred when do decode," + e.getMessage(), e);
}
if (setFutureNull) {
channel.setReadFuture(null);
}
ReleaseUtil.release(future);
foreReadFutureAcceptor.accept(channel.getSession(), future);
}
}
Aggregations