OpenShot Audio Library | OpenShotAudio 0.3.2
Loading...
Searching...
No Matches
juce_TimeSliceThread.h
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2017 - ROLI Ltd.
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 The code included in this file is provided under the terms of the ISC license
11 http://www.isc.org/downloads/software-support-policy/isc-license. Permission
12 To use, copy, modify, and/or distribute this software for any purpose with or
13 without fee is hereby granted provided that the above copyright notice and
14 this permission notice appear in all copies.
15
16 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
18 DISCLAIMED.
19
20 ==============================================================================
21*/
22
23namespace juce
24{
25
26class TimeSliceThread;
27
28
29//==============================================================================
43class JUCE_API TimeSliceClient
44{
45public:
47 virtual ~TimeSliceClient() = default;
48
64 virtual int useTimeSlice() = 0;
65
66
67private:
68 friend class TimeSliceThread;
69 Time nextCallTime;
70};
71
72
73//==============================================================================
82class JUCE_API TimeSliceThread : public Thread
83{
84public:
85 //==============================================================================
92 explicit TimeSliceThread (const String& threadName);
93
101 ~TimeSliceThread() override;
102
103 //==============================================================================
108 void addTimeSliceClient (TimeSliceClient* clientToAdd, int millisecondsBeforeStarting = 0);
109
114 void moveToFrontOfQueue (TimeSliceClient* clientToMove);
115
120 void removeTimeSliceClient (TimeSliceClient* clientToRemove);
121
126 void removeAllClients();
127
129 int getNumClients() const;
130
132 TimeSliceClient* getClient (int index) const;
133
134 //==============================================================================
135 #ifndef DOXYGEN
136 void run() override;
137 #endif
138
139 //==============================================================================
140private:
141 CriticalSection callbackLock, listLock;
143 TimeSliceClient* clientBeingCalled = nullptr;
144
145 TimeSliceClient* getNextClient (int index) const;
146
147 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TimeSliceThread)
148};
149
150} // namespace juce
virtual int useTimeSlice()=0
virtual ~TimeSliceClient()=default