Periodic TimerTask in netty
ljohnston
johnstlr at yahoo.co.uk
Mon Sep 5 06:28:41 EDT 2011
If I understand you correctly then the short answer is no.
Trustin has plans for Netty 4 which include being able to raise an arbitrary
application event via the I/O worker thread. This might prove suitable for
your needs. However it would probably be wrong to depend on this arriving
within whatever time constraints you have.
http://www.jboss.org/netty/community#nabble-td6696365 See here for details.
At the moment your best option is to use an appropriate timer task (eg, JDK,
a scheduled thread pool or something else) and simply to synchronise your
code appropriately. While I appreciate that you currently see this as a
"limitation" of Netty what you're really asking for is a more generic event
dispatching solution whereas Netty's original remit was as framework for
building event driven network applications. As a (very) simple solution,
what about placing a handler directly below your business logic that
processes timer callbacks and forces serialisation of the netty and timer
threads?
Also in this discussion thread you mention that you do not want to worry
about synchronisation and visibility of data between threads. However you
also mention OrderedMemoryAwareThreadPoolExecutor. If you're using this
executor you must remember that it guarantees that events are executed in
order but it does not guarantee which thread will process the event.
Depending on your architecture you may still need to consider thread
visibility issues.
Cheers
Lee
--
View this message in context: http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Periodic-TimerTask-in-netty-tp6756465p6760432.html
Sent from the Netty User Group mailing list archive at Nabble.com.
More information about the netty-users
mailing list