<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/timers-pending-at-shutdown-w3r7iwp1b" -->

---
title: Timers pending at shutdown | daily.dev
description: This installment of a long-running C++ testing series details a redesign of a timer queue system used in The Server Framework to allow clean shutdown without...
canonical: https://daily.dev/posts/timers-pending-at-shutdown-w3r7iwp1b
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Timers pending at shutdown | daily.dev
og:description: This installment of a long-running C++ testing series details a redesign of a timer queue system used in The Server Framework to allow clean shutdown without...
og:url: https://daily.dev/posts/timers-pending-at-shutdown-w3r7iwp1b
og:image: https://api.daily.dev/og/posts/w3R7iWP1B.png
og:image:alt: Timers pending at shutdown
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Timers pending at shutdown

**[Rambling Comments](https://daily.dev/sources/lenholgate)** · 10 min read · 1 upvotes · 1 comments

## Summary

This installment of a long-running C++ testing series details a redesign of a timer queue system used in The Server Framework to allow clean shutdown without requiring callers to pre-cancel pending timers. The change fires all pending timers at shutdown with a new 'shutdown induced' flag via a new OnTimerEx() function, keeping backwards compatibility with the existing OnTimer(). It walks through splitting the IManageTimerQueue interface into IHandleTimerQueueTimeouts and a new ISupportTimerQueueFacade to preserve correct lock-free dispatch semantics during shutdown, and renaming HandleTimeout() to HandleTimeouts(). Full source is published on GitHub under the MIT license, buildable with Visual Studio 2022 and 2026.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://lenholgate.com/blog/2026/09/practical-testing-44-timers-pending-at-shutdown.html>

## Community discussion

Top comments from developers on daily.dev.

**@nark3d** · 0 upvotes

> Is there a way for a caller to distinguish a shutdown induced timer from a real one without checking the flag at every site, because the flag only helps if the handler is already written to care.  The split into IHandleTimerQueueTimeouts and ISupportTimerQueueFacade reads well, and firing pending timers rather than cancelling them keeps the shutdown path free of caller bookkeeping.  Does HandleTimeouts ever run twice for the same timer when a real timeout and the shutdown race each other?

## Similar posts on daily.dev

- [Timer Queue timers at shutdown](https://daily.dev/posts/timer-queue-timers-at-shutdown-0yhog10tm) · Rambling Comments · 0 upvotes · 0 comments
- [Timer Wheel timers at shutdown](https://daily.dev/posts/timer-wheel-timers-at-shutdown-tq3ug5eii) · Rambling Comments · 0 upvotes · 0 comments
- [Practical Testing: 43](https://daily.dev/posts/practical-testing-43-bcfdxy2eh) · Rambling Comments · 0 upvotes · 0 comments
- [Using request timeouts middleware in web API](https://daily.dev/posts/using-request-timeouts-middleware-in-web-api-ijbjckoyi) · Damir's Corner · 5 upvotes · 1 comments

---

Tags: [#general-programming](https://daily.dev/tags/general-programming), [#testing](https://daily.dev/tags/testing), [#c++](https://daily.dev/tags/c++)

[View this post on daily.dev](https://daily.dev/posts/timers-pending-at-shutdown-w3r7iwp1b)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Timers pending at shutdown","url":"https://daily.dev/posts/timers-pending-at-shutdown-w3r7iwp1b","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/timers-pending-at-shutdown-w3r7iwp1b"},"datePublished":"2026-09-29T08:11:43.212Z","dateModified":"2026-09-29T08:12:03.411Z","description":"This installment of a long-running C++ testing series details a redesign of a timer queue system used in The Server Framework to allow clean shutdown without...","image":"https://media.daily.dev/image/upload/s--0_ODbtD2--/f_auto/v1722860399/public/Placeholder%2008","thumbnailUrl":"https://media.daily.dev/image/upload/s--0_ODbtD2--/f_auto/v1722860399/public/Placeholder%2008","isAccessibleForFree":true,"articleSection":"Rambling Comments","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Rambling Comments","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/6848ae9421714c45987b2b6509433655","url":"https://daily.dev/sources/lenholgate"},"commentCount":1,"discussionUrl":"https://daily.dev/posts/timers-pending-at-shutdown-w3r7iwp1b","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":1}],"keywords":"general-programming,testing,c++","timeRequired":"PT10M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Rambling Comments","item":"https://daily.dev/sources/lenholgate"},{"@type":"ListItem","position":3,"name":"Timers pending at shutdown"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/timers-pending-at-shutdown-w3r7iwp1b","comment":[{"@type":"Comment","text":"Is there a way for a caller to distinguish a shutdown induced timer from a real one without checking the flag at every site, because the flag only helps if the handler is already written to care.  The split into IHandleTimerQueueTimeouts and ISupportTimerQueueFacade reads well, and firing pending timers rather than cancelling them keeps the shutdown path free of caller bookkeeping.  Does HandleTimeouts ever run twice for the same timer when a real timeout and the shutdown race each other?","datePublished":"2026-09-30T16:24:32.709Z","url":"https://daily.dev/posts/w3R7iWP1B#c-n2qswHaKl","author":{"@type":"Person","name":"Adam","url":"https://daily.dev/nark3d","image":"https://avatars.githubusercontent.com/u/2162621?v=4"}}]}
```

