Conversation

implemented software timer using binary heap priority queue. works well as long as no "cancel timer" operation is needed. what is a good data structure for a timer where cancellation is common? (e.g. mostly handling timeouts)
1
Replying to
Option A: Use your binary heap normally, but introduce an intermediate cancellation object wrapping the callback. I.e. use mutation. Option B: Use a finger-tree. In the monoidal summary for each subtree, track priority and the range of cancellation IDs (& optionally tree size).
1
1