HashedWheelTimer & Delegation

Johnny Luong johnny.luong at trustcommerce.com
Thu Nov 18 14:43:29 EST 2010


On 11/18/2010 02:22 AM, Kirtimaan (Gmail) wrote:
> Hi,
>  
> Is it possible to pass a class reference to HashedWheelTimer while setting a
> newTimeout job.
>  
> What I want achieve is using a single HashedWheelTimer object to execute a
> method at fixed interval for each connected client. This method is part of
> business logic and deals with user instance, so defined inside channel
> handler (which is extending IdleStateTimer) and stateful.
>  
> I defined a HashedWheelTimer already for idlestate detection in my custom
> pipeline factory. I thought of defining another one in my main class as
> static member (or even using the same existing instance) to schedule task
> for each client based on condition. Task could be like after every 20 second
> send update to client A, after every 15 second send list of clients to
> client B (means not a single task and depends on conditions and client
> instance).
>  
> One option could be that I extend TimerTask and pass & store my logic class
> reference to that. Then add a time out task using HashedTimeoutTask
> newTimeout(task, delay, unit) where task is object of CustomTimerTask type.
>  
> Using separate Timers doesn't sound like a good idea to me, as that's not
> performance friendly option. Because then it will create a separate thread
> to manage timer for each connected client. Other option which I thought for
> a moment is using something like quartz-scheduler, but then it will make
> stuff little complex for me.
>  
> If its not a proper way to do what I am trying, could any one suggest a
> better or proper way. 
>  
> Thanks,
> Kirtimaan
> 
> 
> 
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users

You should be able to share a single instance of the HashedWheelTimer
for the purposes of scheduling new jobs to run at a fixed interval.  If
the job needs to be re-ran, you could add a new task at the end of the
original task to accomplish the different scheduling considerations.

Best,
Johnny


More information about the netty-users mailing list