Events
"이희승 (Trustin Lee)"
trustin at gmail.com
Sun Jun 7 02:02:16 EDT 2009
On 07-Jun-2009 13:37, Yang Zhang wrote:
> Hi, is there an event handling framework in Netty? I'm writing a
> library on top of Netty that assumes asynchronous IO, so methods that do
> such IO take a callback. However, if for instance I can immediately
> make the callback, and I don't want to simply make a recursive call into
> the callback, how do I issue a new event? (In Twisted, this is done
> with reactor.callLater(delay, callback), where delay is set to 0.)
>
> (More generally, is it possible to issue asynchronous delays/sleeps in
> Netty?)
Hi Yang,
That's an interesting idea. Thanks first of all. :)
You can issue a new event by calling Channels.fireXXX(...),
ChannelPipeline.sendUpstream/Downstream(...), or
ChannelHandlerContext.sendUpstream/Downstream(...). However, the call
is made recursively.
Actually I didn't thought about callLater so far. In what case would it
be useful? How accurate the actual delay should be, or when is it useful?
callLater() with no delay is pretty simple to implement. I wonder how
Twisted Matrix implements delayed event triggering though. Netty has a
HashedWheelTimer which is dedicated to delayed task execution, and you
can do whatever you want with it.
Thanks,
Trustin
--
— Trustin Lee, http://gleamynode.net/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 258 bytes
Desc: OpenPGP digital signature
Url : http://lists.jboss.org/pipermail/netty-users/attachments/20090607/e6f014fc/attachment.bin
More information about the netty-users
mailing list