Skip to content

Single thread timer - #609

Open
skywojciechowskim wants to merge 6 commits into
release/v0.15.2from
feature/RDKEMW-24084
Open

skywojciechowskim wants to merge 6 commits into
release/v0.15.2from
feature/RDKEMW-24084

Conversation

@skywojciechowskim

Copy link
Copy Markdown
Contributor

Summary: Do not create a dedicated thread for each timer to improve the performance
Type: Fix
Test Plan: UT/CT, Fullstack
Jira: RDKEMW-24084

Copilot AI lite review requested due to automatic review settings September 24, 2026 06:47
@github-actions

Copy link
Copy Markdown

Pull request must be merged with a description containing the required fields,

Summary:
Type: Feature/Fix/Cleanup
Test Plan:
Jira:

If there is no jira releated to this change, please put 'Jira: NO-JIRA'.

Description can be changed by editing the top comment on your pull request and making a new commit.

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 and moderate issues affect compilation, callback-thread guarantees, timer lifecycle, and delay handling.

Get a fresh assessment by requesting another Copilot review.

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

Open (5)
What changed in this PR

Refactors timers to use a shared GLib event-loop thread instead of one thread per timer.

Changes:

  • Adds shared GLib timer scheduling and callback management.
  • Replaces per-timer thread state with GLib source IDs.
  • Adds GLib/GStreamer build dependencies.
File Summary
common/​source/​Timer.cpp Implements shared timer scheduling; unresolved lifecycle, threading, range, cleanup, and compilation issues remain.
common/​include/​Timer.h Replaces thread-based state with a GLib source ID.
common/​CMakeLists.txt Adds required GLib/GStreamer dependencies.

💡 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
Comment on lines +59 to +60
m_loop = g_main_loop_new(nullptr, FALSE);
m_thread = std::thread([this]() { g_main_loop_run(m_loop); });
Comment thread common/source/Timer.cpp
static_cast<guint>(timeout.count()),
[](gpointer data) -> gboolean
{
auto callback = CommonTimerLoop::instance().getTimerCallback(static_cast<Timer *>(data));
Comment thread common/source/Timer.cpp
Comment on lines +116 to +117
m_timerId = g_timeout_add(
static_cast<guint>(timeout.count()),
Comment thread common/source/Timer.cpp
Comment on lines +136 to +140
auto callback = CommonTimerLoop::instance().getTimerCallback(static_cast<Timer *>(data));
if (callback)
{
if (m_active && m_callback)
{
lock.unlock();
m_callback();
}
callback();
CommonTimerLoop::instance().removeTimerCallback(static_cast<Timer *>(data));
Comment thread common/source/Timer.cpp
bool Timer::isActive() const
{
return m_active;
return CommonTimerLoop::instance().getTimerCallback(this) != nullptr;
@github-actions

Copy link
Copy Markdown

Coverage statistics of your commit:
Congratulations, your commit improved lines coverage from: 0.0% to 84.4%
Congratulations, your commit improved functions coverage from: 0.0% to 92.6%

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.

2 participants