Loading...
Searching...
No Matches
juce_Timer.h
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2022 - Raw Material Software Limited
JUCE is an open source library subject to commercial or open-source
licensing.
The code included in this file is provided under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
To use, copy, modify, and/or distribute this software for any purpose with or
without fee is hereby granted provided that the above copyright notice and
this permission notice appear in all copies.
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
namespace juce
{
//==============================================================================
class JUCE_API Timer
{
protected:
//==============================================================================
Timer() noexcept;
Timer (const Timer&) noexcept;
public:
//==============================================================================
virtual ~Timer();
//==============================================================================
virtual void timerCallback() = 0;
//==============================================================================
void startTimer (int intervalInMilliseconds) noexcept;
void startTimerHz (int timerFrequencyHz) noexcept;
void stopTimer() noexcept;
//==============================================================================
bool isTimerRunning() const noexcept { return timerPeriodMs > 0; }
int getTimerInterval() const noexcept { return timerPeriodMs; }
//==============================================================================
static void JUCE_CALLTYPE callAfterDelay (int milliseconds, std::function<void()> functionToCall);
//==============================================================================
static void JUCE_CALLTYPE callPendingTimersSynchronously();
private:
class TimerThread;
size_t positionInQueue = (size_t) -1;
int timerPeriodMs = 0;
SharedResourcePointer<TimerThread> timerThread;
Timer& operator= (const Timer&) = delete;
};
} // namespace juce
juce::SharedResourcePointer
Definition juce_SharedResourcePointer.h:82
juce::Timer
Definition juce_Timer.h:52
juce::Timer::stopTimer
void stopTimer() noexcept
Definition juce_Timer.cpp:332
juce::Timer::getTimerInterval
int getTimerInterval() const noexcept
Definition juce_Timer.h:116
juce::Timer::Timer
Timer() noexcept
Definition juce_Timer.cpp:293
juce::Timer::startTimerHz
void startTimerHz(int timerFrequencyHz) noexcept
Definition juce_Timer.cpp:324
juce::Timer::isTimerRunning
bool isTimerRunning() const noexcept
Definition juce_Timer.h:111
juce::Timer::startTimer
void startTimer(int intervalInMilliseconds) noexcept
Definition juce_Timer.cpp:309
juce::Timer::timerCallback
virtual void timerCallback()=0