← Back to Pull requests

refactor(timers): unify the duplicated ClockConditionalVariable implementations #3401

Open
unknown opened this pull request with 316 lines diff across 3 files
View on GitHub
unknown unknown commented on Nov 06, 2026 20:33 UTC
Author

Description

<!--
Please include a summary of the changes and the related issue.
Highlight any key points or areas of concern.
-->

The timer manager in #3097 introduced a variant of ClockWaiter and ClockConditionalVariable which could accept a clock on its wait_until calls instead of at construction. This PR unifies both ClockWaiter and ClockConditionalVariable under one set which can do both, and removes the duplicates in timer_manager.

  • ClockWaiter and ClockConditionalVariable can now accept a null clock at construction, and both gain a wait_until(lock, clock, until, pred) overload. The existing overloads without a clock are unchanged.

  • The clock given to a wait is only used for that call and is never stored, so the timer queue doesn't keep a timer's clock alive.

  • ClockConditionalVariable keeps one ClockWaiter for its whole lifetime, so notify_one() takes no lock and a wait performs no allocation.

  • TimerQueue uses rclcpp::ClockConditionalVariable directly, now constructed with a null clock.

  • A wait with no clock (none given at construction or on the call), or a null clock passed to the new overload, throws std::runtime_error. Before, waiting without a clock dereferenced a null pointer.

  • If the timer thread's wait throws while the context is still valid, it now logs an error before stopping that queue's timers. Before, it stopped them silently. During shutdown it stays quiet, as before.
  • <!--
    Automatically closes linked issue when PR is merged.
    Usage: Fixes #<issue number>, or Fixes (paste link of issue).

    -->

    Is this user-facing behavior change?

    <!--
    If no, just leave this section empty.
    If yes, please explain how user-experience changes with this pull request.
    -->

    rclcpp::ClockConditionalVariable::wait_until() used to return true unconditionally. It now returns false if the context was shut down before the call. Callers that ignored the return value need no change.

    A wait whose until doesn't match the clock's type now throws before it starts, on every clock type.

    Did you use Generative AI?

    <!--
    If this pull request was generated using Generative AI, please specify the tool and model used (e.g., GitHub Copilot, GPT-4.1).
    If only specific parts were generated by Generative AI, please list those parts (e.g., function A, class B, etc.).
    -->
    Yes, Claude Opus 5.5

    Additional Information

    <!--
    If applicable, provide any additional context or details about the changes.
    -->

    Diff: 316 lines (+237 / -79) across 3 files Reviewer: skyegalaxy Review duration: 34638m
    All Vouch review confidence checks passed
    Residual risk 0.22 = Change Risk (0.40) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 316 lines diff across 3 files
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.345
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #3401"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 40.4% (MEDIUM) · Higher = larger blast radius
    40.4%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 21.5% · Safe to merge
    21.5%
    Repository