53 if (clientBeingCalled ==
client)
92 return clients.
size();
107 for (
int i = clients.
size(); --i >= 0;)
127 int timeToWait = 500;
134 const ScopedLock sl2 (listLock);
136 numClients = clients.
size();
137 index = numClients > 0 ? ((index + 1) % numClients) : 0;
139 if (
auto* firstClient = getNextClient (index))
140 nextClientTime = firstClient->nextCallTime;
147 if (nextClientTime > now)
149 timeToWait = (int) jmin ((int64) 500, (nextClientTime - now).inMilliseconds());
153 timeToWait = index == 0 ? 1 : 0;
155 const ScopedLock sl (callbackLock);
158 const ScopedLock sl2 (listLock);
159 clientBeingCalled = getNextClient (index);
162 if (clientBeingCalled !=
nullptr)
164 const int msUntilNextCall = clientBeingCalled->
useTimeSlice();
166 const ScopedLock sl2 (listLock);
168 if (msUntilNextCall >= 0)
173 clientBeingCalled =
nullptr;
Holds a resizable array of primitive or copy-by-value objects.
ElementType getUnchecked(int index) const
Returns one of the elements in the array, without checking the index passed in.
int size() const noexcept
Returns the current number of elements in the array.
void removeFirstMatchingValue(ParameterType valueToRemove)
Removes an item from the array.
bool contains(ParameterType elementToLookFor) const
Returns true if the array contains at least one occurrence of an object.
bool addIfNotAlreadyThere(ParameterType newElement)
Appends a new element at the end of the array as long as the array doesn't already contain it.
static RelativeTime milliseconds(int milliseconds) noexcept
Creates a new RelativeTime object representing a number of milliseconds.
bool wait(int timeOutMilliseconds) const
Suspends the execution of this thread until either the specified timeout period has elapsed,...
virtual void run()=0
Must be implemented to perform the thread's actual code.
bool threadShouldExit() const
Checks whether the thread has been told to stop running.
bool stopThread(int timeOutMilliseconds)
Attempts to stop the thread running.
void notify() const
Wakes up the thread.
Used by the TimeSliceThread class.
virtual int useTimeSlice()=0
Called back by a TimeSliceThread.
int getNumClients() const
Returns the number of registered clients.
void removeTimeSliceClient(TimeSliceClient *clientToRemove)
Removes a client from the list.
void addTimeSliceClient(TimeSliceClient *clientToAdd, int millisecondsBeforeStarting=0)
Adds a client to the list.
~TimeSliceThread() override
Destructor.
TimeSliceClient * getClient(int index) const
Returns one of the registered clients.
void moveToFrontOfQueue(TimeSliceClient *clientToMove)
If the given client is waiting in the queue, it will be moved to the front and given a time-slice as ...
void removeAllClients()
Removes all the active and pending clients from the list.
TimeSliceThread(const String &threadName)
Creates a TimeSliceThread.
Holds an absolute date and time.
static Time JUCE_CALLTYPE getCurrentTime() noexcept
Returns a Time object that is set to the current system time.