Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
wtholliday committed Aug 8, 2023
1 parent 2cd27a7 commit f1c76db
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions Sources/CAudio/AudioProgram.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ class AudioProgram {
AUAudioFrameCount frameCount,
AudioBufferList* outputBufferList,
int workerIndex,
std::vector<WorkStealingQueue<int>>& runQueues) {
std::vector<std::shared_ptr<WorkStealingQueue<int>>>& runQueues) {

auto exec = [&](int index) {
auto& job = jobs[index];

Expand All @@ -52,7 +52,7 @@ class AudioProgram {
// Increment outputs.
for (int outputIndex : job->outputIndices) {
if (finished[outputIndex].fetch_add(1, std::memory_order_relaxed) == jobs[outputIndex]->inputCount()) {
runQueues[workerIndex].push(outputIndex);
runQueues[workerIndex]->push(outputIndex);
}
}

Expand All @@ -61,14 +61,14 @@ class AudioProgram {

while (remaining.load(std::memory_order_relaxed) > 0) {
// Pop an index off our queue.
if (auto index = runQueues[workerIndex].pop()) {
if (auto index = runQueues[workerIndex]->pop()) {
exec(*index);
} else {
// Try to steal an index. Start with the next worker and wrap around,
// but don't steal from ourselves.
for (int i = 0; i < runQueues.size() - 1; ++i) {
int victim = (workerIndex + i) % runQueues.size();
if (auto index = runQueues[victim].steal()) {
if (auto index = runQueues[victim]->steal()) {
exec(*index);
break;
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/CAudio/WorkerThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class WorkerThread {
AUAudioFrameCount frameCount = 0;

/// Our main output buffer.
vector<AudioBufferList> outputBufferList;
AudioBufferList* _Nonnull outputBufferList;

/// Queue for submitting jobs to the worker.
vector<RenderJobIndex> initialJobs;
Expand Down Expand Up @@ -128,9 +128,9 @@ class WorkerThread {
program->run(&actionFlags,
&timeStamp,
frameCount,
&outputBufferList,
outputBufferList,
workerIndex,
&runQueues);
runQueues);
} else {
printf("worker has no program!");
}
Expand Down

0 comments on commit f1c76db

Please sign in to comment.