Skip to content

RDKEMW-15488: Remove per-call mutex/cv allocation in MainThread - #634

Merged
bvanav merged 2 commits into
masterfrom
feature/RDKEMW-15488
Oct 20, 2026
Merged

bvanav merged 2 commits into
masterfrom
feature/RDKEMW-15488

Conversation

@bvanav

@bvanav bvanav commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary: Remove per-call mutex/cv allocation in MainThread
Type: Fix
Test Plan: UT/CT, Fullstack
Jira: RDKEMW-15488

Copilot AI balanced review requested due to automatic review settings October 15, 2026 06:39
@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.

🟢 Approval recommended

Completion remains synchronized before thread-local state can be reused or destroyed, and no blocking issues remain.

0 open findings

What changed in this PR

Reduces allocation overhead in MainThread’s synchronous task submission by reusing thread-local completion state.

Changes:

  • Reuses a mutex and condition variable for each calling thread in both blocking enqueue methods.
  • Updates task completion signaling to use the shared completion-state structure.
File Description
media/​server/​main/​source/​MainThread.cpp Reuses thread-local state for blocking calls and completion signaling.
media/​server/​main/​include/​MainThread.h Adds TaskState and replaces per-task synchronization pointers.

🧠 Review effort: Balanced


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

@github-actions

Copy link
Copy Markdown

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

@bvanav
bvanav force-pushed the feature/RDKEMW-15488 branch from ff7aefa to aa892ce Compare October 15, 2026 07:28
A calling thread will be blocked inside enqueueTaskAndWait/enqueuePriorityTaskAndWait until the task completes,
so we can reuse one mutex/cv per thread instead of allocating them for every call.
This will avoid unnecessary heap allocations for std::mutex and std::condition_variable.
@bvanav
bvanav force-pushed the feature/RDKEMW-15488 branch from aa892ce to d8d6042 Compare October 15, 2026 07:29
Copilot AI balanced review requested due to automatic review settings October 15, 2026 07:29

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.

🟢 Approval recommended

No blocking issues were identified in synchronization, completion-state reuse, or lifetime handling.

0 open findings

🧠 Review effort: Balanced

@github-actions

Copy link
Copy Markdown

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

1 similar comment
@github-actions

Copy link
Copy Markdown

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

@bvanav bvanav changed the title Remove per-call mutex/cv allocation in MainThread RDKEMW-15488: Remove per-call mutex/cv allocation in MainThread Oct 20, 2026
Copilot AI balanced review requested due to automatic review settings October 20, 2026 16:00

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.

🟢 Approval recommended

No blocking issues were identified in synchronization, completion-state reuse, or state lifetime.

No open issues 🎉

Review effort: Balanced

@github-actions

Copy link
Copy Markdown

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

@bvanav
bvanav merged commit 0be7c8b into master Oct 20, 2026
41 of 48 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 20, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants