openshot-audio  0.1.6
juce_TimeSliceThread.h
Go to the documentation of this file.
1 /*
2  ==============================================================================
3 
4  This file is part of the juce_core module of the JUCE library.
5  Copyright (c) 2015 - ROLI Ltd.
6 
7  Permission to use, copy, modify, and/or distribute this software for any purpose with
8  or without fee is hereby granted, provided that the above copyright notice and this
9  permission notice appear in all copies.
10 
11  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
12  TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
13  NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
15  IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
16  CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 
18  ------------------------------------------------------------------------------
19 
20  NOTE! This permissive ISC license applies ONLY to files within the juce_core module!
21  All other JUCE modules are covered by a dual GPL/commercial license, so if you are
22  using any other modules, be sure to check that you also comply with their license.
23 
24  For more details, visit www.juce.com
25 
26  ==============================================================================
27 */
28 
29 #ifndef JUCE_TIMESLICETHREAD_H_INCLUDED
30 #define JUCE_TIMESLICETHREAD_H_INCLUDED
31 
32 class TimeSliceThread;
33 
34 
35 //==============================================================================
48 {
49 public:
51  virtual ~TimeSliceClient() {}
52 
68  virtual int useTimeSlice() = 0;
69 
70 
71 private:
72  friend class TimeSliceThread;
73  Time nextCallTime;
74 };
75 
76 
77 //==============================================================================
85 {
86 public:
87  //==============================================================================
94  explicit TimeSliceThread (const String& threadName);
95 
103  ~TimeSliceThread();
104 
105  //==============================================================================
111  void addTimeSliceClient (TimeSliceClient* client, int millisecondsBeforeStarting = 0);
112 
118  void removeTimeSliceClient (TimeSliceClient* client);
119 
124  void moveToFrontOfQueue (TimeSliceClient* client);
125 
127  int getNumClients() const;
128 
130  TimeSliceClient* getClient (int index) const;
131 
132  //==============================================================================
133  #ifndef DOXYGEN
134  void run() override;
135  #endif
136 
137  //==============================================================================
138 private:
139  CriticalSection callbackLock, listLock;
140  Array <TimeSliceClient*> clients;
141  TimeSliceClient* clientBeingCalled;
142 
143  TimeSliceClient* getNextClient (int index) const;
144 
146 };
147 
148 
149 #endif // JUCE_TIMESLICETHREAD_H_INCLUDED
CriticalSection callbackLock
Definition: juce_mac_CoreMidi.cpp:258
virtual void run()=0
Definition: juce_TimeSliceThread.h:47
Definition: juce_Time.h:41
Definition: juce_String.h:43
#define JUCE_API
Definition: juce_StandardHeader.h:139
Definition: juce_CriticalSection.h:47
Definition: juce_Array.h:60
Definition: juce_Thread.h:47
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
Definition: juce_PlatformDefs.h:198
Definition: juce_TimeSliceThread.h:84
virtual ~TimeSliceClient()
Definition: juce_TimeSliceThread.h:51