Skip to content

Conversation

@poneciak57
Copy link
Contributor

Closes RNAA-263
Closes RNAA-259

Implemented simple thread pool which allows for blazingly fast task dispatch. It has some limitations and allow dispatch only from one thread. It is not thread safe. To make it safer while mantaining the speed multi-producer multi-consumer queue/channel would be required. But for now it seems sufficient cuz we want to mostly offload audio thread and still we can create multiple PromiseVendors.

⚠️ Breaking changes ⚠️

Introduced changes

Checklist

  • Linked relevant issue
  • Updated relevant documentation
  • Added/Conducted relevant tests
  • Performed self-review of the code
  • Updated Web Audio API coverage
  • Added support for web

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Introduces a lock-free single-producer thread pool and integrates it into PromiseVendor to offload asynchronous promise work from ad-hoc std::thread creation.

  • Adds ThreadPool with load balancer and worker threads using SPSC channels.
  • Replaces per-promise detached thread creation with pooled task scheduling.
  • Adds configurable constants for thread pool sizing.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
audioapi/utils/ThreadPool.hpp New thread pool implementation (load balancer + worker queues).
audioapi/jsi/JsiPromise.h Integrates a shared ThreadPool into PromiseVendor.
audioapi/jsi/JsiPromise.cpp Uses ThreadPool->schedule instead of spawning detached threads.
audioapi/core/utils/Constants.h Adds sizing constants for the thread pool.

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@maciejmakowski2003
Copy link
Collaborator

LGTM

Copy link
Member

@michalsek michalsek left a comment

Choose a reason for hiding this comment

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

one nit, good job! :)

@michalsek michalsek changed the title Feat/thread pool Thread pool Oct 3, 2025
@michalsek michalsek added the feature New feature label Oct 3, 2025
@poneciak57 poneciak57 merged commit c7f242d into main Oct 3, 2025
3 checks passed
@maciejmakowski2003 maciejmakowski2003 deleted the feat/thread-pool-impl branch October 24, 2025 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants