get timer instance from ReadTimeoutHandler subclasses

"Trustin Lee (이희승)" trustin at gmail.com
Wed Mar 24 01:40:09 EDT 2010


Timer is shared by many connections, and therefore it's not efficient to
call Timer.start() in channelConnected().  If you want to start the
timer thread explicitly before communication starts, you'd better call
Timer.start() before calling ServerBootstrap.bind() or
ClientBootstrap.connect().

HTH,
Trustin

谢非 wrote:
> hi all,
> 
>     I need to start the timeout timer in channelConnected() event handler of
> a ReadTimeoutHandler subclass, but it seems that there is no protected
> getTimer() in ReadTimeoutHandler.
>     should I store the timer as a member field like this:
> 
>       class ServerReadTimeoutHandler extends ReadTimeoutHandler {
>              Timer timer;
> 
>              public ServerReadTimeoutHandler(Timer timer, int
> timeoutSeconds) {
>                          super(timer, timeoutSeconds);
>                           this.timer = timer;
>              }
> 
>             @Override
>             public void channelConnected(ChannelHandlerContext ctx,
> ChannelStateEvent e) throws Exception {
>                  timer.start();
>                  super.channelConnected(ctx, e);
>             }
>      }
> 
> Centaur
> 20100318
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users

-- 
what we call human nature in actuality is human habit
http://gleamynode.net/


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 260 bytes
Desc: OpenPGP digital signature
Url : http://lists.jboss.org/pipermail/netty-users/attachments/20100324/1edacddf/attachment-0001.bin 


More information about the netty-users mailing list