get timer instance from ReadTimeoutHandler subclasses

谢非 heliu.smth at gmail.com
Wed Mar 24 01:53:45 EDT 2010


if the  timer is started implicitly and shared ,  what is the start point
for an individual connection?
channelOpened?

Or can I use one timer for each connection to achieve a more accurate start
point control?

Centaur
20100324

2010/3/24 "Trustin Lee (이희승)" <trustin at gmail.com>

> 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/
>
>
>
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/netty-users/attachments/20100324/6ba6d44d/attachment-0001.html 


More information about the netty-users mailing list