mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-17 00:44:19 +00:00
Added method Timer::startTimerHz
This commit is contained in:
parent
7c42fc102a
commit
9e36c4ecca
2 changed files with 14 additions and 5 deletions
|
|
@ -332,6 +332,14 @@ void Timer::startTimer (const int interval) noexcept
|
|||
}
|
||||
}
|
||||
|
||||
void Timer::startTimerHz (int timerFrequencyHz) noexcept
|
||||
{
|
||||
if (timerFrequencyHz > 0)
|
||||
startTimer (1000 / timerFrequencyHz);
|
||||
else
|
||||
stopTimer();
|
||||
}
|
||||
|
||||
void Timer::stopTimer() noexcept
|
||||
{
|
||||
const TimerThread::LockType::ScopedLockType sl (TimerThread::lock);
|
||||
|
|
|
|||
|
|
@ -91,6 +91,11 @@ public:
|
|||
*/
|
||||
void startTimer (int intervalInMilliseconds) noexcept;
|
||||
|
||||
/** Starts the timer with an interval specified in Hertz.
|
||||
This is effectively the same as calling startTimer (1000 / timerFrequencyHz).
|
||||
*/
|
||||
void startTimerHz (int timerFrequencyHz) noexcept;
|
||||
|
||||
/** Stops the timer.
|
||||
|
||||
No more callbacks will be made after this method returns.
|
||||
|
|
@ -102,14 +107,10 @@ public:
|
|||
void stopTimer() noexcept;
|
||||
|
||||
//==============================================================================
|
||||
/** Checks if the timer has been started.
|
||||
|
||||
@returns true if the timer is running.
|
||||
*/
|
||||
/** Returns true if the timer is currently running. */
|
||||
bool isTimerRunning() const noexcept { return periodMs > 0; }
|
||||
|
||||
/** Returns the timer's interval.
|
||||
|
||||
@returns the timer's interval in milliseconds if it's running, or 0 if it's not.
|
||||
*/
|
||||
int getTimerInterval() const noexcept { return periodMs; }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue