Cancelling a time out event
"이희승 (Trustin Lee)"
trustin at gmail.com
Wed Nov 10 02:15:58 EST 2010
I'd use compareAndSet(false, true) instead of get() and set() on both
sides to avoid possible race condition.
// processing part:
if (flag.compareAndSet(false, true)) {
// process
} else {
// close requested - don't process
}
// closing part:
if (flag.compareAndSet(false, true)) {
// close
} else {
// processing - don't close.
}
HTH
Marc-André Laverdière wrote:
> Hello everyone,
>
> I have a pipeline with a timeout handler. Now, it happens that the
> timeout event gets triggered while the processing is happening. This
> is what I hacked into place into my main handler:
>
> @Override
> public void closeRequested(ChannelHandlerContext ctx,
> ChannelStateEvent e) throws Exception {
> //Don't let operations time out in the middle of request processing
> //This is a downstream event, so we can cancel its Future
> if (isHandlingRequest.get()) {
> e.getFuture().cancel();
> logger.trace("Cancelled close request because we are in the middle
> of processing something");
> } else super.closeRequested(ctx, e);
> }
>
> Is this the right way to handle this? Is this creating extraneous
> processing that could hurt performance?
>
> Thanks and regards,
>
> Marc-André LAVERDIÈRE
> "Perseverance must finish its work so that you may be mature and
> complete, not lacking anything." -James 1:4
> http://asimplediscipleslife.blogspot.com/
> mlaverd.theunixplace.com
>
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users
--
Trustin Lee - http://gleamynode.net/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 290 bytes
Desc: OpenPGP digital signature
Url : http://lists.jboss.org/pipermail/netty-users/attachments/20101110/4187d605/attachment.bin
More information about the netty-users
mailing list