Skip to content

Commit

Permalink
DeferredMainThreadAction: add bool return value (#479)
Browse files Browse the repository at this point in the history
  • Loading branch information
jatinchowdhury18 authored Dec 30, 2023
1 parent 9b071d6 commit aa6c011
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)
{
if (juce::MessageManager::existsAndIsCurrentThread())
{
operationToDefer();
return;
return true;
}

auto success = true;
if (couldBeAudioThread)
{
const auto success = queue.try_enqueue (std::forward<Callable> (operationToDefer));
success = queue.try_enqueue (std::forward<Callable> (operationToDefer));

// 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;
}

private:
Expand Down

0 comments on commit aa6c011

Please sign in to comment.