OpenShot Library | libopenshot-audio
0.2.0
juce_HighResolutionTimer.h
1
2
/** @weakgroup juce_core-threads
3
* @{
4
*/
5
/*
6
==============================================================================
7
8
This file is part of the JUCE library.
9
Copyright (c) 2017 - ROLI Ltd.
10
11
JUCE is an open source library subject to commercial or open-source
12
licensing.
13
14
The code included in this file is provided under the terms of the ISC license
15
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
16
To use, copy, modify, and/or distribute this software for any purpose with or
17
without fee is hereby granted provided that the above copyright notice and
18
this permission notice appear in all copies.
19
20
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
21
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
22
DISCLAIMED.
23
24
==============================================================================
25
*/
26
27
namespace
juce
28
{
29
30
/**
31
A high-resolution periodic timer.
32
33
This provides accurately-timed regular callbacks. Unlike the normal Timer
34
class, this one uses a dedicated thread, not the message thread, so is
35
far more stable and precise.
36
37
You should only use this class in situations where you really need accuracy,
38
because unlike the normal Timer class, which is very lightweight and cheap
39
to start/stop, the HighResolutionTimer will use far more resources, and
40
starting/stopping it may involve launching and killing threads.
41
42
@see Timer
43
44
@tags{Core}
45
*/
46
class
JUCE_API
HighResolutionTimer
47
{
48
protected
:
49
/** Creates a HighResolutionTimer.
50
When created, the timer is stopped, so use startTimer() to get it going.
51
*/
52
HighResolutionTimer
();
53
54
public
:
55
/** Destructor. */
56
virtual
~
HighResolutionTimer
();
57
58
//==============================================================================
59
/** The user-defined callback routine that actually gets called periodically.
60
61
This will be called on a dedicated timer thread, so make sure your
62
implementation is thread-safe!
63
64
It's perfectly ok to call startTimer() or stopTimer() from within this
65
callback to change the subsequent intervals.
66
*/
67
virtual
void
hiResTimerCallback() = 0;
68
69
//==============================================================================
70
/** Starts the timer and sets the length of interval required.
71
72
If the timer is already started, this will reset its counter, so the
73
time between calling this method and the next timer callback will not be
74
less than the interval length passed in.
75
76
@param intervalInMilliseconds the interval to use (any values less than 1 will be
77
rounded up to 1)
78
*/
79
void
startTimer (
int
intervalInMilliseconds);
80
81
/** Stops the timer.
82
83
This method may block while it waits for pending callbacks to complete. Once it
84
returns, no more callbacks will be made. If it is called from the timer's own thread,
85
it will cancel the timer after the current callback returns.
86
*/
87
void
stopTimer();
88
89
/** Checks if the timer has been started.
90
@returns true if the timer is running.
91
*/
92
bool
isTimerRunning()
const
noexcept;
93
94
/** Returns the timer's interval.
95
@returns the timer's interval in milliseconds if it's running, or 0 if it's not.
96
*/
97
int
getTimerInterval()
const
noexcept;
98
99
private
:
100
struct
Pimpl;
101
std::unique_ptr<Pimpl> pimpl;
102
103
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (
HighResolutionTimer
)
104
};
105
106
}
// namespace juce
107
108
/** @}*/
JUCE_API
#define JUCE_API
This macro is added to all JUCE public class declarations.
Definition:
juce_StandardHeader.h:143
juce::HighResolutionTimer
A high-resolution periodic timer.
Definition:
juce_HighResolutionTimer.h:46
juce_core
threads
juce_HighResolutionTimer.h
Generated on Mon Jun 29 2020 19:03:32 for OpenShot Library | libopenshot-audio by
1.8.17