Skip to content

Commit

Permalink
DeferredMainThreadAction: add bool return value
Browse files Browse the repository at this point in the history
  • Loading branch information
jatinchowdhury18 committed Dec 7, 2023
1 parent f71f380 commit 9561469
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,22 @@ class DeferredAction : public juce::Timer
* thread, make sure to set `couldBeAudioThread = true`.
*/
template <typename Callable>
void call (Callable&& operationToDefer, bool couldBeAudioThread = false)
bool call (Callable&& operationToDefer, bool couldBeAudioThread = false)

Check warning on line 46 in modules/plugin/chowdsp_plugin_utils/Threads/chowdsp_DeferredMainThreadAction.h

View check run for this annotation

Codecov / codecov/patch

modules/plugin/chowdsp_plugin_utils/Threads/chowdsp_DeferredMainThreadAction.h#L46

Added line #L46 was not covered by tests
{
if (juce::MessageManager::existsAndIsCurrentThread())
{
operationToDefer();
return;
return true;

Check warning on line 51 in modules/plugin/chowdsp_plugin_utils/Threads/chowdsp_DeferredMainThreadAction.h

View check run for this annotation

Codecov / codecov/patch

modules/plugin/chowdsp_plugin_utils/Threads/chowdsp_DeferredMainThreadAction.h#L51

Added line #L51 was not covered by tests
}

auto success = true;

Check warning on line 54 in modules/plugin/chowdsp_plugin_utils/Threads/chowdsp_DeferredMainThreadAction.h

View check run for this annotation

Codecov / codecov/patch

modules/plugin/chowdsp_plugin_utils/Threads/chowdsp_DeferredMainThreadAction.h#L54

Added line #L54 was not covered by tests
if (couldBeAudioThread)
{
const auto success = queue.try_enqueue (std::forward<Callable> (operationToDefer));
success = queue.try_enqueue (std::forward<Callable> (operationToDefer));

Check warning on line 57 in modules/plugin/chowdsp_plugin_utils/Threads/chowdsp_DeferredMainThreadAction.h

View check run for this annotation

Codecov / codecov/patch

modules/plugin/chowdsp_plugin_utils/Threads/chowdsp_DeferredMainThreadAction.h#L57

Added line #L57 was not covered by tests

// The queue doesn't have enough space for all these messages!
// Consider changing the default size of the queue.
jassert (success);
juce::ignoreUnused (success);
}
else
{
Expand All @@ -68,6 +68,7 @@ class DeferredAction : public juce::Timer
}

callbacksReady.store (true);
return success;

Check warning on line 71 in modules/plugin/chowdsp_plugin_utils/Threads/chowdsp_DeferredMainThreadAction.h

View check run for this annotation

Codecov / codecov/patch

modules/plugin/chowdsp_plugin_utils/Threads/chowdsp_DeferredMainThreadAction.h#L71

Added line #L71 was not covered by tests
}

private:
Expand Down

0 comments on commit 9561469

Please sign in to comment.