HashedWheelTimer TimerTask may execute after call to Timeout.cancel()
Trustin Lee
trustin at gmail.com
Fri Aug 12 00:46:42 EDT 2011
Hi Ron,
I like the alternative 2. However, could you explain why the public
methods in HashedWheelTimeout should be synchronized? Is there
anything thread-unsafe there?
Thanks
On Tue, Aug 9, 2011 at 4:54 PM, <rzo at gmx.de> wrote:
> Hello,
>
> given that the implementation is using "approximated times" a call to Timeout.cancel() may not cancel the task.
>
> I think that the problem is:
>
> public void cancel() {
> if (isExpired()) {
> return;
> }
>
>
> where isExpired checks:
>
> System.currentTimeMillis() > deadline
>
> Solution:
> Alternative 1:
>
> remove the check:
>
> if (isExpired()) {
> return;
> }
>
> Alternative 2:
>
> new field:
>
> boolean expired = false.
>
> this is set to true in:
>
> HashedWheelTimeout.expire()
>
> and isExpired()
> {
> return canceled || expired;
> }
>
>
> I also propose that the public methods on HashedWheelTimeout be synchronized.
>
> What do you think ?
>
> -- Ron
> http://sourceforge.net/projects/yajsw
> --
> NEU: FreePhone - 0ct/min Handyspartarif mit Geld-zurück-Garantie!
> Jetzt informieren: http://www.gmx.net/de/go/freephone
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users
--
Trustin Lee, http://gleamynode.net/
More information about the netty-users
mailing list