summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_timer.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2018-10-22Handling of timers with bias.Valentin Bartenev1-15/+22
Timers that don't require maximum precision (most of them, actually) can be triggered earlier or later within the bias interval. To reduce wakeups by timers, the expire function now triggers not only all timers that fall within the elapsed time, but also those whose bias falls within this interval.
2018-10-22Timers: separation of delete and insert operations on rbtree.Valentin Bartenev1-10/+20
Delete/insert operation complexity for a red-black tree is O(log n), where n is the total number of tree elements. If all delete operations are performed before all insert operations, the average number of tree elements during an operation will be lower than in the mixed-operations case.
2018-10-22Re-engineered timers.Valentin Bartenev1-82/+53
To optimize rbtree operations, all changes are stored in array and later processed in batches. The previous implementation of this mechanics had a number of design flaws. Each change was saved in a new array entry; until the changes were applied, the timer remained in an intermediate state (NXT_TIMER_CHANGING). This intermediate state didn't allow to identify if time was going to be disabled or enabled. However, the nxt_conn_io_read() function relied on this information; as a result, in some cases the read timeout wasn't set. Also, the nxt_timer_delete() function did not reliably track whether a timer was added to the work queue. It checked the NXT_TIMER_ENQUEUED state of a timer, but this state could be reset to NXT_TIMER_DISABLED by a nxt_timer_disable() call or another nxt_timer_delete() call. Now, instead of keeping the whole history of the timer's changes, the new implementation updates the timer state immediately, and only one operation is added to the array to add or delete timer in the rbtree according to its final state.
2018-03-28Using type for nxt_msec_diff().Igor Sysoev1-4/+5
2018-01-24Fixed formatting in nxt_sprintf() and logging.Sergey Kandaurov1-1/+1
2017-11-27Timer should be marked as it is not in tree after deletion.Igor Sysoev1-0/+1
This closes #64 issue on GitHub.
2017-01-31Event engine timers refactoring.Igor Sysoev1-134/+170
2017-01-30nxt_event_timer has been renamed to nxt_timer.Igor Sysoev1-0/+317