Skip to content

Single thread timer - #607

Open
skywojciechowskim wants to merge 7 commits into
masterfrom
SingleThreadTimer
Open

skywojciechowskim wants to merge 7 commits into
masterfrom
SingleThreadTimer

Conversation

@skywojciechowskim

Copy link
Copy Markdown
Contributor

RDKEMW-24084: Single thread timer

Reason for change: Do not create a dedicated thread for each timer to improve the performance
Test Procedure: Rialto CI

Copilot AI lite review requested due to automatic review settings September 22, 2026 12:29
@github-actions

Copy link
Copy Markdown

Pull request title must follow the pattern:
< JIRA TICKET >: < one line summary of change less than 65 characters >

Pull request description must follow the Commit message format for RDK-E:
https://etwiki.sys.comcast.net/spaces/RDKAR/pages/1407997180/Commit+Message+Format+For+RDKE

  1. Associated JIRA ticket in format : < JIRA TICKET >: < one line summary of change less than 65 characters >
  2. Detailed reason for change information
  3. Test procedure. Only references links to Jira ticket or sub tickets where test steps and references are captured.

< JIRA TICKET >: < one line summary of change less than 65 characters >
< empty line >
Reason for change:
Test Procedure: < https://ccp.sys.comcast.net/browse/JIRA TICKET/url/to/test_step_section>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Unresolved critical timer-ID race and additional context, compatibility, and dependency findings.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity

Open (1)
What changed in this PR

This PR replaces per-timer threads with a shared GLib timer-loop thread.

Changes:

  • Adds shared one-shot and periodic GLib timer scheduling.
  • Stores GLib source IDs instead of timer thread state.
  • Updates build dependencies for GLib/GStreamer integration.
File Summary and review status
common/​source/​Timer.cpp Implements shared timer scheduling. Critical issue (2 votes): timer ID publication can race with callback dispatch. Moderate issues (1 vote each): use a private main context and address g_timeout_add_once GLib 2.74 compatibility.
common/​include/​Timer.h Updates timer state to use GLib source identifiers.
common/​CMakeLists.txt Adds build dependencies. Nit (1 vote): link directly to glib-2.0 instead of unrelated GStreamer modules.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread common/source/Timer.cpp Outdated
@github-actions

Copy link
Copy Markdown

Coverage statistics of your commit:
Congratulations, your commit improved lines coverage from: 85.0% to 85.1%
Congratulations, your commit improved functions coverage from: 93.4% to 93.5%

Copilot AI review requested due to automatic review settings September 23, 2026 06:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

A critical callback-lifetime issue and multiple moderate correctness and dependency issues remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 2 High severity

Open (2)
Previously missed (2)

In code that hasn't changed since last review

Medium severity Use a private GLib main context for timer sources

common/​source/​Timer.cpp:38

Passing nullptr selects GLib's process-wide default GMainContext, and both g_timeout_add calls below attach their sources to that same context. Running it from this worker can contend with or dispatch unrelated default-context sources, and timers may stop firing if another loop owns the context. Use a private context for the shared timer loop and attach each timer source to it.

Medium severity Clear active state when one-shot timer fires

common/​source/​Timer.cpp:118

g_timeout_add_once removes the source after this callback, but m_active is never cleared here. Consequently every one-shot timer that fires naturally continues to report isActive() == true until someone explicitly calls cancel(), unlike the previous implementation (which set it false when the thread exited). Clear the active flag after the callback, including when the callback is empty.

Comment thread common/source/Timer.cpp Outdated
@github-actions

Copy link
Copy Markdown

Coverage statistics of your commit:
Congratulations, your commit improved lines coverage from: 85.0% to 85.1%
Congratulations, your commit improved functions coverage from: 93.4% to 93.5%

Copilot AI review requested due to automatic review settings September 23, 2026 12:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Unresolved timer initialization, lifecycle, cancellation, registration, and context-isolation issues block approval.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity

Open (1)
Resolved since last review (2)
Previously missed (1)

In code that hasn't changed since last review

Medium severity One-shot timer remains active after expiration

common/​source/​Timer.cpp:140

A one-shot timer never transitions m_active to false when its source fires, so isActive() remains true after expiration. This also leaves the timer looking live to callers until destruction; clear the active state and remove the source ID independently of whether a callback is present.

Comment thread common/include/Timer.h Outdated
@github-actions

Copy link
Copy Markdown

Coverage statistics of your commit:
Congratulations, your commit improved lines coverage from: 84.4% to 85.1%
Congratulations, your commit improved functions coverage from: 92.7% to 93.5%

Copilot AI review requested due to automatic review settings September 24, 2026 06:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Critical timer lifecycle and dispatch issues, plus callback, duration, and dependency concerns remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 2 High severity · 1 Medium severity

Open (3)
Resolved since last review (1)

Comment thread common/source/Timer.cpp
Comment thread common/source/Timer.cpp
Comment thread common/source/Timer.cpp
Copilot AI review requested due to automatic review settings September 24, 2026 06:48
@github-actions

Copy link
Copy Markdown

Coverage statistics of your commit:
Congratulations, your commit improved lines coverage from: 85.0% to 85.1%
Congratulations, your commit improved functions coverage from: 93.4% to 93.5%

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Unresolved issues affect cancellation safety, timer cleanup, context ownership, and GLib compatibility.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 4 High severity · 1 Medium severity

Open (5)

Comment thread common/source/Timer.cpp
Comment thread common/source/Timer.cpp
@github-actions

Copy link
Copy Markdown

Coverage statistics of your commit:
Congratulations, your commit improved lines coverage from: 85.0% to 85.1%
Congratulations, your commit improved functions coverage from: 93.4% to 93.5%

Copilot AI lite review requested due to automatic review settings September 30, 2026 13:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Timer cancellation and callback state have unresolved safety and cleanup issues, and the build introduces an unnecessary client-side dependency.

Review effort: Lite
Findings: None

Resolved since last review (5)

@github-actions

Copy link
Copy Markdown

Coverage statistics of your commit:
Lines coverage stays unchanged and is: 84.6%
Functions coverage stays unchanged and is: 92.8%

This branch has not been deployed

No deployments
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.

3 participants