Skip to content

Refactor TimerQueue to use unique_ptr and sequence-based indexing.#737

Open
Sakura1221 wants to merge 1 commit into
chenshuo:masterfrom
Sakura1221:optimize-timer-queue
Open

Refactor TimerQueue to use unique_ptr and sequence-based indexing.#737
Sakura1221 wants to merge 1 commit into
chenshuo:masterfrom
Sakura1221:optimize-timer-queue

Conversation

@Sakura1221

@Sakura1221 Sakura1221 commented Jun 4, 2026

Copy link
Copy Markdown
  • Own Timer objects in timerMap_; index expiration/active sets by timer id
  • Create and destroy Timer objects on the event-loop thread
  • TimerId holds sequence only (no Timer*); cancel uses sequence
  • Assert timerMap find on paths that require the timer to exist

Public EventLoop timer API unchanged. Timer.h unchanged.

- Own Timer objects in timerMap_; index expiration/active sets by timer id
- Create and destroy Timer on the event-loop thread (addTimer posts runInLoop;
  timerMap_ cleared in ~TimerQueue on loop thread)
- Issue TimerId from nextTimerId_; construct Timer inside addTimerInLoop only
- TimerId holds sequence only (no Timer*); cancel uses sequence
- Assert timerMap find on paths that require the timer to exist

Public EventLoop timer API unchanged. Timer.h unchanged.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant