LMMS
Loading...
Searching...
No Matches
juce_MultiTimer.cpp
Go to the documentation of this file.
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
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
27{
29 : owner (mt), timerID (tid)
30 {
31 }
32
33 void timerCallback() override
34 {
35 owner.timerCallback (timerID);
36 }
37
39 const int timerID;
40
42};
43
44//==============================================================================
47
53
54//==============================================================================
55Timer* MultiTimer::getCallback (int timerID) const noexcept
56{
57 for (int i = timers.size(); --i >= 0;)
58 {
59 MultiTimerCallback* const t = static_cast<MultiTimerCallback*> (timers.getUnchecked(i));
60
61 if (t->timerID == timerID)
62 return t;
63 }
64
65 return nullptr;
66}
67
68void MultiTimer::startTimer (const int timerID, const int intervalInMilliseconds) noexcept
69{
71
72 Timer* timer = getCallback (timerID);
73
74 if (timer == nullptr)
75 timers.add (timer = new MultiTimerCallback (timerID, *this));
76
77 timer->startTimer (intervalInMilliseconds);
78}
79
80void MultiTimer::stopTimer (const int timerID) noexcept
81{
83
84 if (Timer* const t = getCallback (timerID))
85 t->stopTimer();
86}
87
88bool MultiTimer::isTimerRunning (const int timerID) const noexcept
89{
91
92 if (Timer* const t = getCallback (timerID))
93 return t->isTimerRunning();
94
95 return false;
96}
97
98int MultiTimer::getTimerInterval (const int timerID) const noexcept
99{
101
102 if (Timer* const t = getCallback (timerID))
103 return t->getTimerInterval();
104
105 return 0;
106}
107
108} // namespace juce
#define noexcept
Definition DistrhoDefines.h:72
Definition juce_MultiTimer.h:46
MultiTimer() noexcept
Definition juce_MultiTimer.cpp:45
OwnedArray< Timer > timers
Definition juce_MultiTimer.h:119
int getTimerInterval(int timerID) const noexcept
Definition juce_MultiTimer.cpp:98
void stopTimer(int timerID) noexcept
Definition juce_MultiTimer.cpp:80
Timer * getCallback(int) const noexcept
Definition juce_MultiTimer.cpp:55
SpinLock timerListLock
Definition juce_MultiTimer.h:118
bool isTimerRunning(int timerID) const noexcept
Definition juce_MultiTimer.cpp:88
void startTimer(int timerID, int intervalInMilliseconds) noexcept
Definition juce_MultiTimer.cpp:68
virtual ~MultiTimer()
Definition juce_MultiTimer.cpp:48
GenericScopedLock< SpinLock > ScopedLockType
Definition juce_SpinLock.h:73
Definition juce_Timer.h:52
Timer() noexcept
Definition juce_Timer.cpp:316
void startTimer(int intervalInMilliseconds) noexcept
Definition juce_Timer.cpp:332
struct huft * t
Definition inflate.c:943
register unsigned i
Definition inflate.c:1575
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
Definition carla_juce.cpp:31
static const Bit8u mt[16]
Definition nukedopl.c:138
Definition juce_MultiTimer.cpp:27
MultiTimerCallback(const int tid, MultiTimer &mt) noexcept
Definition juce_MultiTimer.cpp:28
MultiTimer & owner
Definition juce_MultiTimer.cpp:38
const int timerID
Definition juce_MultiTimer.cpp:39
void timerCallback() override
Definition juce_MultiTimer.cpp:33