Event Timers and RB trees
agentzh
agentzh at gmail.com
Mon Jan 4 05:18:00 MSK 2010
On Sat, Jan 2, 2010 at 12:29 AM, test guy <testguy103 at gmail.com> wrote:
>
> I have been looking through the nginx source code and cannot figure out how event timers are used (and their purpose). Can somebody shed some light on this for me please?
>
Timers are usually used to implement the timeout mechanism for
non-blocking I/O operations in nginx. But it is also used to implement
non-blocking sleep in the ngx_chunkin module. Logically, a timer is
usually associated with an ngx_event_t object, and at any one time,
only one timer is allowed for one ngx_event_t object.
Two functions are often used to handle timers, ngx_add_timer and ngx_del_timer.
> Also, I noticed a red/black tree is used somehow with event timers, and I also do not understand this.
>
It's used to store the timers themselves. It's the implementation
details already, I think ;)
Cheers,
-agentzh
More information about the nginx-devel
mailing list