Loading...
Searching...
No Matches
juce_TimeSliceThread.h
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2022 - Raw Material Software Limited
JUCE is an open source library subject to commercial or open-source
licensing.
The code included in this file is provided under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
To use, copy, modify, and/or distribute this software for any purpose with or
without fee is hereby granted provided that the above copyright notice and
this permission notice appear in all copies.
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
namespace juce
{
class TimeSliceThread;
//==============================================================================
class JUCE_API TimeSliceClient
{
public:
virtual ~TimeSliceClient() = default;
virtual int useTimeSlice() = 0;
private:
friend class TimeSliceThread;
Time nextCallTime;
};
//==============================================================================
class JUCE_API TimeSliceThread : public Thread
{
public:
//==============================================================================
explicit TimeSliceThread (const String& threadName);
~TimeSliceThread() override;
//==============================================================================
void addTimeSliceClient (TimeSliceClient* clientToAdd, int millisecondsBeforeStarting = 0);
void moveToFrontOfQueue (TimeSliceClient* clientToMove);
void removeTimeSliceClient (TimeSliceClient* clientToRemove);
void removeAllClients();
int getNumClients() const;
TimeSliceClient* getClient (int index) const;
bool contains (const TimeSliceClient*) const;
//==============================================================================
#ifndef DOXYGEN
void run() override;
#endif
//==============================================================================
private:
CriticalSection callbackLock, listLock;
Array<TimeSliceClient*> clients;
TimeSliceClient* clientBeingCalled = nullptr;
TimeSliceClient* getNextClient (int index) const;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TimeSliceThread)
};
} // namespace juce
juce::Array
Definition juce_Array.h:56
juce::CriticalSection
Definition juce_CriticalSection.h:43
juce::String
Definition juce_String.h:53
juce::Thread::Thread
Thread(const String &threadName, size_t threadStackSize=osDefaultStackSize)
Definition juce_Thread.cpp:26
juce::TimeSliceClient
Definition juce_TimeSliceThread.h:44
juce::TimeSliceClient::useTimeSlice
virtual int useTimeSlice()=0
juce::TimeSliceClient::~TimeSliceClient
virtual ~TimeSliceClient()=default
juce::TimeSliceThread
Definition juce_TimeSliceThread.h:83
juce::TimeSliceThread::getNumClients
int getNumClients() const
Definition juce_TimeSliceThread.cpp:90
juce::TimeSliceThread::removeTimeSliceClient
void removeTimeSliceClient(TimeSliceClient *clientToRemove)
Definition juce_TimeSliceThread.cpp:47
juce::TimeSliceThread::addTimeSliceClient
void addTimeSliceClient(TimeSliceClient *clientToAdd, int millisecondsBeforeStarting=0)
Definition juce_TimeSliceThread.cpp:36
juce::TimeSliceThread::getClient
TimeSliceClient * getClient(int index) const
Definition juce_TimeSliceThread.cpp:96
juce::TimeSliceThread::moveToFrontOfQueue
void moveToFrontOfQueue(TimeSliceClient *clientToMove)
Definition juce_TimeSliceThread.cpp:79
juce::TimeSliceThread::contains
bool contains(const TimeSliceClient *) const
Definition juce_TimeSliceThread.cpp:102
juce::TimeSliceThread::removeAllClients
void removeAllClients()
Definition juce_TimeSliceThread.cpp:68
juce::TimeSliceThread::run
void run() override
Definition juce_TimeSliceThread.cpp:128
juce::TimeSliceThread::TimeSliceThread
TimeSliceThread(const String &threadName)
Definition juce_TimeSliceThread.cpp:26
juce::Time
Definition juce_Time.h:37