|
JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins
« « « Anklang Documentation |
Makes repeated callbacks to a virtual method at a specified time interval. More...
#include "juce_Timer.h"
Classes | |
| class | TimerThread |
Public Member Functions | |
| virtual | ~Timer () |
| Destructor. | |
| virtual void | timerCallback ()=0 |
| The user-defined callback routine that actually gets called periodically. | |
| void | startTimer (int intervalInMilliseconds) noexcept |
| Starts the timer and sets the length of interval required. | |
| void | startTimerHz (int timerFrequencyHz) noexcept |
| Starts the timer with an interval specified in Hertz. | |
| void | stopTimer () noexcept |
| Stops the timer. | |
| bool | isTimerRunning () const noexcept |
| Returns true if the timer is currently running. | |
| int | getTimerInterval () const noexcept |
| Returns the timer's interval. | |
Static Public Member Functions | |
| static void JUCE_CALLTYPE | callAfterDelay (int milliseconds, std::function< void()> functionToCall) |
| Invokes a lambda after a given number of milliseconds. | |
| static void JUCE_CALLTYPE | callPendingTimersSynchronously () |
| For internal use only: invokes any timers that need callbacks. | |
Protected Member Functions | |
| Timer () noexcept | |
| Creates a Timer. | |
| Timer (const Timer &) noexcept | |
| Creates a copy of another timer. | |
Makes repeated callbacks to a virtual method at a specified time interval.
A Timer's timerCallback() method will be repeatedly called at a given interval. When you create a Timer object, it will do nothing until the startTimer() method is called, which will cause the message thread to start making callbacks at the specified interval, until stopTimer() is called or the object is deleted.
The time interval isn't guaranteed to be precise to any more than maybe 10-20ms, and the intervals may end up being much longer than requested if the system is busy. Because the callbacks are made by the main message thread, anything that blocks the message queue for a period of time will also prevent any timers from running until it can carry on.
If you need to have a single callback that is shared by multiple timers with different frequencies, then the MultiTimer class allows you to do that - its structure is very similar to the Timer class, but contains multiple timers internally, each one identified by an ID number.
@tags{Events}
Definition at line 51 of file juce_Timer.h.
|
protectednoexcept |
Creates a Timer.
When created, the timer is stopped, so use startTimer() to get it going.
Definition at line 280 of file juce_Timer.cpp.
Creates a copy of another timer.
Note that this timer won't be started, even if the one you're copying is running.
Definition at line 281 of file juce_Timer.cpp.
|
virtual |
Destructor.
Definition at line 283 of file juce_Timer.cpp.
|
static |
Invokes a lambda after a given number of milliseconds.
Definition at line 359 of file juce_Timer.cpp.
|
static |
For internal use only: invokes any timers that need callbacks.
Don't call this unless you really know what you're doing!
Definition at line 328 of file juce_Timer.cpp.
|
noexcept |
Returns the timer's interval.
Definition at line 116 of file juce_Timer.h.
|
noexcept |
Returns true if the timer is currently running.
Definition at line 111 of file juce_Timer.h.
Starts the timer and sets the length of interval required.
If the timer is already started, this will reset it, so the time between calling this method and the next timer callback will not be less than the interval length passed in.
| intervalInMilliseconds | the interval to use (any value less than 1 will be rounded up to 1) |
Definition at line 296 of file juce_Timer.cpp.
Starts the timer with an interval specified in Hertz.
This is effectively the same as calling startTimer (1000 / timerFrequencyHz).
Definition at line 311 of file juce_Timer.cpp.
|
noexcept |
Stops the timer.
No more timer callbacks will be triggered after this method returns.
Note that if you call this from a background thread while the message-thread is already in the middle of your callback, then this method will cancel any future timer callbacks, but it will return without waiting for the current one to finish. The current callback will continue, possibly still running some of your timer code after this method has returned.
Definition at line 319 of file juce_Timer.cpp.
The user-defined callback routine that actually gets called periodically.
It's perfectly ok to call startTimer() or stopTimer() from within this callback to change the subsequent intervals.
Implemented in juce::LambdaInvoker, juce::SimpleDeviceManagerInputLevelMeter, juce::MidiKeyboardComponent, juce::AutoRemovingTransportSource, juce::MultiTimerCallback, juce::ImageCache::Pimpl, juce::Button::CallbackHelper, juce::detail::MouseInputSourceList, juce::ImagePreviewComponent, juce::PopupMenu::HelperClasses::MouseSourceState, juce::DragAndDropContainer::DragImageComponent, juce::Slider::Pimpl::PopupDisplayComponent, juce::TextEditor::TextHolderComponent, juce::CallOutBoxCallback, and juce::BubbleMessageComponent.