HashedWheelTimer & Delegation
kirtimaan.mg
kirtimaan.mg at gmail.com
Fri Nov 19 02:47:20 EST 2010
Hi Johnny,
Thanks for reply. So then I need to extend TimerTask to share reference of
my main class (in order to access methods defined in main class) ? Or
HashedWheelTimer provides a way to avoid such referencing?
Regards,
Kirtimaan
-------Original Message-------
From: Johnny Luong-2 [via Netty Forums and Mailing Lists]
Date: 11/19/10 01:15:48
To: kirtimaan.mg
Subject: Re: HashedWheelTimer & Delegation
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
> [hidden email]
> 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
_______________________________________________
netty-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/netty-users
View message @ http://netty-forums-and-mailing-lists.685743.n2.nabble
com/HashedWheelTimer-Delegation-tp5751088p5753040.html
To start a new topic under Netty User Group, email
ml-node+685700-1479029216-303201 at n2.nabble.com
To unsubscribe from Netty User Group, click here.
--
View this message in context: http://netty-forums-and-mailing-lists.685743.n2.nabble.com/HashedWheelTimer-Delegation-tp5751088p5754431.html
Sent from the Netty User Group mailing list archive at Nabble.com.
More information about the netty-users
mailing list