JUCE v8.0.9
JUCE API
 
Loading...
Searching...
No Matches
juce::ThreadWithProgressWindow Class Referenceabstract

A thread that automatically pops up a modal dialog box with a progress bar and cancel button while it's busy running. More...

#include <juce_ThreadWithProgressWindow.h>

Inheritance diagram for juce::ThreadWithProgressWindow:
Collaboration diagram for juce::ThreadWithProgressWindow:

Public Types

enum class  Priority {
  highest = 2 ,
  high = 1 ,
  normal = 0 ,
  low = -1 ,
  background = -2
}
 The different runtime priorities of non-realtime threads. More...
 
using ThreadID = void *
 A value type used for thread IDs.
 

Public Member Functions

 ThreadWithProgressWindow (const String &windowTitle, bool hasProgressBar, bool hasCancelButton, int timeOutMsWhenCancelling=10000, const String &cancelButtonText=String(), Component *componentToCentreAround=nullptr)
 Creates the thread.
 
 ~ThreadWithProgressWindow () override
 Destructor.
 
void addListener (Listener *)
 Add a listener to this thread which will receive a callback when signalThreadShouldExit was called on this thread.
 
AlertWindowgetAlertWindow () const noexcept
 Returns the AlertWindow that is being used.
 
ThreadID getThreadId () const noexcept
 Returns the ID of this thread.
 
const StringgetThreadName () const noexcept
 Returns the name of the thread.
 
bool isRealtime () const
 Returns true if this Thread represents a realtime thread.
 
bool isThreadRunning () const
 Returns true if the thread is currently active.
 
void launchThread (Priority priority=Priority::normal)
 Starts the thread and returns.
 
void notify () const
 Wakes up the thread.
 
void removeListener (Listener *)
 Removes a listener added with addListener.
 
virtual void run ()=0
 Must be implemented to perform the thread's actual code.
 
bool runThread (Priority priority=Priority::normal)
 Starts the thread and waits for it to finish.
 
void setAffinityMask (uint32 affinityMask)
 Sets the affinity mask for the thread.
 
void setProgress (double newProgress)
 The thread should call this periodically to update the position of the progress bar.
 
void setStatusMessage (const String &newStatusMessage)
 The thread can call this to change the message that's displayed in the dialog box.
 
void signalThreadShouldExit ()
 Sets a flag to tell the thread it should stop.
 
bool startRealtimeThread (const RealtimeOptions &options)
 Starts the thread with realtime performance characteristics on platforms that support it.
 
bool startThread ()
 Attempts to start a new thread with default ('Priority::normal') priority.
 
bool startThread (Priority newPriority)
 Attempts to start a new thread with a given priority.
 
bool stopThread (int timeOutMilliseconds)
 Attempts to stop the thread running.
 
virtual void threadComplete (bool userPressedCancel)
 This method is called (on the message thread) when the operation has finished.
 
bool threadShouldExit () const
 Checks whether the thread has been told to stop running.
 
bool wait (double timeOutMilliseconds) const
 Suspends the execution of this thread until either the specified timeout period has elapsed, or another thread calls the notify() method to wake it up.
 
bool waitForThreadToExit (int timeOutMilliseconds) const
 Waits for the thread to stop.
 

Static Public Member Functions

static bool currentThreadShouldExit ()
 Checks whether the current thread has been told to stop running.
 
static ThreadgetCurrentThread ()
 Finds the thread object that is currently running.
 
static ThreadID getCurrentThreadId ()
 Returns an id that identifies the caller thread.
 
static void initialiseJUCE (void *jniEnv, void *jContext)
 Initialises the JUCE subsystem for projects not created by the Projucer.
 
static bool launch (Priority priority, std::function< void()> functionToRun)
 Invokes a lambda or function on its own thread with a custom priority.
 
static bool launch (std::function< void()> functionToRun)
 Invokes a lambda or function on its own thread with the default priority.
 
static void setCurrentThreadAffinityMask (uint32 affinityMask)
 Changes the affinity mask for the caller thread.
 
static void setCurrentThreadName (const String &newThreadName)
 Changes the name of the caller thread.
 
static void sleep (int milliseconds)
 Suspends the execution of the current thread until the specified timeout period has elapsed (note that this may not be exact).
 
static void yield ()
 Yields the current thread's CPU time-slot and allows a new thread to run.
 

Static Public Attributes

static constexpr size_t osDefaultStackSize { 0 }
 

Protected Member Functions

Priority getPriority () const
 Returns the current priority of this thread.
 
bool setPriority (Priority newPriority)
 Attempts to set the priority for this thread.
 

Private Member Functions

void closeThreadHandle ()
 
bool createNativeThread (Priority)
 
int getTimerInterval () const noexcept
 Returns the timer's interval.
 
bool isTimerRunning () const noexcept
 Returns true if the timer is currently running.
 
void killThread ()
 
bool startThreadInternal (Priority)
 
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.
 
void threadEntryPoint ()
 
void timerCallback () override
 The user-defined callback routine that actually gets called periodically.
 

Static Private Member Functions

static void callAfterDelay (int milliseconds, std::function< void()> functionToCall)
 Invokes a lambda after a given number of milliseconds.
 
static void callPendingTimersSynchronously ()
 For internal use only: invokes any timers that need callbacks.
 

Private Attributes

uint32 affinityMask = 0
 
std::unique_ptr< AlertWindowalertWindow
 
WaitableEvent defaultEvent
 
bool deleteOnThreadEnd = false
 
ThreadSafeListenerList< Listenerlisteners
 
String message
 
CriticalSection messageLock
 
size_t positionInQueue = (size_t) -1
 
std::atomic< Prioritypriority
 
double progress
 
std::optional< RealtimeOptionsrealtimeOptions = {}
 
std::atomic< boolshouldExit { false }
 
CriticalSection startStopLock
 
WaitableEvent startSuspensionEvent
 
std::atomic< void * > threadHandle { nullptr }
 
std::atomic< ThreadIDthreadId { nullptr }
 
const String threadName
 
size_t threadStackSize
 
const int timeOutMsWhenCancelling
 
int timerPeriodMs = 0
 
SharedResourcePointer< TimerThread > timerThread
 
bool wasCancelledByUser
 

Detailed Description

A thread that automatically pops up a modal dialog box with a progress bar and cancel button while it's busy running.

These are handy for performing some sort of task while giving the user feedback about how long there is to go, etc.

E.g.

class MyTask : public ThreadWithProgressWindow
{
public:
MyTask() : ThreadWithProgressWindow ("busy...", true, true)
{
}
void run()
{
for (int i = 0; i < thingsToDo; ++i)
{
// must check this as often as possible, because this is
// how we know if the user's pressed 'cancel'
if (threadShouldExit())
break;
// this will update the progress bar on the dialog box
setProgress (i / (double) thingsToDo);
// ... do the business here...
}
}
};
void doTheTask()
{
MyTask m;
if (m.runThread())
{
// thread finished normally..
}
else
{
// user pressed the cancel button..
}
}
A thread that automatically pops up a modal dialog box with a progress bar and cancel button while it...
Definition juce_ThreadWithProgressWindow.h:94
const GLfloat * m
Definition juce_gl.h:6285
See also
Thread, AlertWindow

@tags{GUI}

Member Typedef Documentation

◆ ThreadID

using juce::Thread::ThreadID = void*
inherited

A value type used for thread IDs.

See also
getCurrentThreadId(), getThreadId()

Member Enumeration Documentation

◆ Priority

enum class juce::Thread::Priority
stronginherited

The different runtime priorities of non-realtime threads.

See also
startThread
Enumerator
highest 

The highest possible priority that isn't a dedicated realtime thread.

high 

Makes use of performance cores and higher clocks.

normal 

The OS default.

It will balance out across all cores.

low 

Uses efficiency cores when possible.

background 

Restricted to efficiency cores on platforms that have them.

Constructor & Destructor Documentation

◆ ThreadWithProgressWindow()

juce::ThreadWithProgressWindow::ThreadWithProgressWindow ( const String windowTitle,
bool  hasProgressBar,
bool  hasCancelButton,
int  timeOutMsWhenCancelling = 10000,
const String cancelButtonText = String(),
Component componentToCentreAround = nullptr 
)

Creates the thread.

Initially, the dialog box won't be visible, it'll only appear when the runThread() method is called.

Parameters
windowTitlethe title to go at the top of the dialog box
hasProgressBarwhether the dialog box should have a progress bar (see setProgress() )
hasCancelButtonwhether the dialog box should have a cancel button
timeOutMsWhenCancellingwhen 'cancel' is pressed, this is how long to wait for the thread to stop before killing it forcibly (see Thread::stopThread() )
cancelButtonTextthe text that should be shown in the cancel button (if it has one). Leave this empty for the default "Cancel"
componentToCentreAroundif this is non-null, the window will be positioned so that it's centred around this component.

◆ ~ThreadWithProgressWindow()

juce::ThreadWithProgressWindow::~ThreadWithProgressWindow ( )
override

Destructor.

Member Function Documentation

◆ addListener()

void juce::Thread::addListener ( Listener )
inherited

Add a listener to this thread which will receive a callback when signalThreadShouldExit was called on this thread.

See also
signalThreadShouldExit, removeListener

◆ callAfterDelay()

static void juce::Timer::callAfterDelay ( int  milliseconds,
std::function< void()>  functionToCall 
)
staticinherited

Invokes a lambda after a given number of milliseconds.

◆ callPendingTimersSynchronously()

static void juce::Timer::callPendingTimersSynchronously ( )
staticinherited

For internal use only: invokes any timers that need callbacks.

Don't call this unless you really know what you're doing!

◆ closeThreadHandle()

void juce::Thread::closeThreadHandle ( )
privateinherited

◆ createNativeThread()

bool juce::Thread::createNativeThread ( Priority  )
privateinherited

◆ currentThreadShouldExit()

static bool juce::Thread::currentThreadShouldExit ( )
staticinherited

Checks whether the current thread has been told to stop running.

On the message thread, this will always return false, otherwise it will return threadShouldExit() called on the current thread.

See also
threadShouldExit

◆ getAlertWindow()

AlertWindow * juce::ThreadWithProgressWindow::getAlertWindow ( ) const
inlinenoexcept

Returns the AlertWindow that is being used.

◆ getCurrentThread()

static Thread * juce::Thread::getCurrentThread ( )
staticinherited

Finds the thread object that is currently running.

Note that the main UI thread (or other non-JUCE threads) don't have a Thread object associated with them, so this will return nullptr.

◆ getCurrentThreadId()

Thread::ThreadID juce::Thread::getCurrentThreadId ( )
staticinherited

Returns an id that identifies the caller thread.

To find the ID of a particular thread object, use getThreadId().

Returns
a unique identifier that identifies the calling thread.
See also
getThreadId

Referenced by juce::ThreadLocalValue< Type >::get(), and juce::ThreadLocalValue< Type >::releaseCurrentThreadStorage().

◆ getPriority()

Priority juce::Thread::getPriority ( ) const
protectedinherited

Returns the current priority of this thread.

This can only be called from the target thread. Doing so from another thread will cause an assert.

See also
setPriority

◆ getThreadId()

ThreadID juce::Thread::getThreadId ( ) const
noexceptinherited

Returns the ID of this thread.

That means the ID of this thread object - not of the thread that's calling the method. This can change when the thread is started and stopped, and will be invalid if the thread's not actually running.

See also
getCurrentThreadId

◆ getThreadName()

const String & juce::Thread::getThreadName ( ) const
inlinenoexceptinherited

Returns the name of the thread.

This is the name that gets set in the constructor.

◆ getTimerInterval()

int juce::Timer::getTimerInterval ( ) const
inlinenoexceptinherited

Returns the timer's interval.

Returns
the timer's interval in milliseconds if it's running, or 0 if it's not.

Referenced by juce::detail::MouseInputSourceList::beginDragAutoRepeat(), and juce::detail::TopLevelWindowManager::checkFocus().

◆ initialiseJUCE()

static void juce::Thread::initialiseJUCE ( void *  jniEnv,
void *  jContext 
)
staticinherited

Initialises the JUCE subsystem for projects not created by the Projucer.

On Android, JUCE needs to be initialised once before it is used. The Projucer will automatically generate the necessary java code to do this. However, if you are using JUCE without the Projucer or are creating a library made with JUCE intended for use in non-JUCE apks, then you must call this method manually once on apk startup.

You can call this method from C++ or directly from java by calling the following java method:

com.rmsl.juce.Java.initialiseJUCE (myContext);

Note that the above java method is only available in Android Studio projects created by the Projucer. If you need to call this from another type of project then you need to add the following java file to your project:

package com.rmsl.juce;
public class Java
{
static { System.loadLibrary ("juce_jni"); }
public native static void initialiseJUCE (Context context);
}
Parameters
jniEnvthis is a pointer to JNI's JNIEnv variable. Any callback from Java into C++ will have this passed in as it's first parameter.
jContextthis is a jobject referring to your app/service/receiver/ provider's Context. JUCE needs this for many of it's internal functions.

◆ isRealtime()

bool juce::Thread::isRealtime ( ) const
inherited

Returns true if this Thread represents a realtime thread.

◆ isThreadRunning()

bool juce::Thread::isThreadRunning ( ) const
inherited

Returns true if the thread is currently active.

Referenced by juce::detail::MessageThread::isRunning().

◆ isTimerRunning()

bool juce::Timer::isTimerRunning ( ) const
inlinenoexceptinherited

Returns true if the timer is currently running.

◆ killThread()

void juce::Thread::killThread ( )
privateinherited

◆ launch() [1/2]

static bool juce::Thread::launch ( Priority  priority,
std::function< void()>  functionToRun 
)
staticinherited

Invokes a lambda or function on its own thread with a custom priority.

This will spin up a Thread object which calls the function and then exits. Bear in mind that starting and stopping a thread can be a fairly heavyweight operation, so you might prefer to use a ThreadPool if you're kicking off a lot of short background tasks.

Also note that using an anonymous thread makes it very difficult to interrupt the function when you need to stop it, e.g. when your app quits. So it's up to you to deal with situations where the function may fail to stop in time.

Parameters
priorityThe priority the thread is started with.
functionToRunThe lambda to be called from the new Thread.
Returns
true if the thread started successfully, or false if it failed.

◆ launch() [2/2]

static bool juce::Thread::launch ( std::function< void()>  functionToRun)
staticinherited

Invokes a lambda or function on its own thread with the default priority.

This will spin up a Thread object which calls the function and then exits. Bear in mind that starting and stopping a thread can be a fairly heavyweight operation, so you might prefer to use a ThreadPool if you're kicking off a lot of short background tasks.

Also note that using an anonymous thread makes it very difficult to interrupt the function when you need to stop it, e.g. when your app quits. So it's up to you to deal with situations where the function may fail to stop in time.

Parameters
functionToRunThe lambda to be called from the new Thread.
Returns
true if the thread started successfully, or false if it failed.
See also
launch.

◆ launchThread()

void juce::ThreadWithProgressWindow::launchThread ( Priority  priority = Priority::normal)

Starts the thread and returns.

This will start the thread and make the dialog box appear in a modal state. When the thread finishes normally, or the cancel button is pressed, the window will be hidden and the threadComplete() method will be called.

Parameters
prioritythe priority to use when starting the thread - see Thread::Priority for values

◆ notify()

void juce::Thread::notify ( ) const
inherited

Wakes up the thread.

If the thread has called the wait() method, this will wake it up.

See also
wait

◆ removeListener()

void juce::Thread::removeListener ( Listener )
inherited

Removes a listener added with addListener.

◆ run()

virtual void juce::Thread::run ( )
pure virtualinherited

Must be implemented to perform the thread's actual code.

Remember that the thread must regularly check the threadShouldExit() method whilst running, and if this returns true it should return from the run() method as soon as possible to avoid being forcibly killed.

See also
threadShouldExit, startThread

Implemented in juce::ThreadedAnalyticsDestination::EventDispatcher, juce::MidiOutput, juce::detail::MessageThread, juce::InterprocessConnectionServer, juce::NetworkServiceDiscovery::Advertiser, and juce::NetworkServiceDiscovery::AvailableServiceList.

◆ runThread()

bool juce::ThreadWithProgressWindow::runThread ( Priority  priority = Priority::normal)

Starts the thread and waits for it to finish.

This will start the thread, make the dialog box appear, and wait until either the thread finishes normally, or until the cancel button is pressed.

Before returning, the dialog box will be hidden.

Parameters
prioritythe priority to use when starting the thread - see Thread::Priority for values
Returns
true if the thread finished normally; false if the user pressed cancel

◆ setAffinityMask()

void juce::Thread::setAffinityMask ( uint32  affinityMask)
inherited

Sets the affinity mask for the thread.

This will only have an effect next time the thread is started - i.e. if the thread is already running when called, it'll have no effect.

See also
setCurrentThreadAffinityMask

◆ setCurrentThreadAffinityMask()

void juce::Thread::setCurrentThreadAffinityMask ( uint32  affinityMask)
staticinherited

Changes the affinity mask for the caller thread.

This will change the affinity mask for the thread that calls this static method.

See also
setAffinityMask

References juce::Thread::affinityMask, jassertfalse, JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE, and JUCE_END_IGNORE_WARNINGS_GCC_LIKE.

◆ setCurrentThreadName()

void juce::Thread::setCurrentThreadName ( const String newThreadName)
staticinherited

Changes the name of the caller thread.

Different OSes may place different length or content limits on this name.

References JUCE_AUTORELEASEPOOL.

◆ setPriority()

bool juce::Thread::setPriority ( Priority  newPriority)
protectedinherited

Attempts to set the priority for this thread.

Returns true if the new priority was set successfully, false if not.

This can only be called from the target thread. Doing so from another thread will cause an assert.

Parameters
newPriorityThe new priority to be applied to the thread. Note: This has no effect on Linux platforms, subsequent calls to 'getPriority' will return this value.
See also
Priority

◆ setProgress()

void juce::ThreadWithProgressWindow::setProgress ( double  newProgress)

The thread should call this periodically to update the position of the progress bar.

Parameters
newProgressthe progress, from 0.0 to 1.0
See also
setStatusMessage

◆ setStatusMessage()

void juce::ThreadWithProgressWindow::setStatusMessage ( const String newStatusMessage)

The thread can call this to change the message that's displayed in the dialog box.

◆ signalThreadShouldExit()

void juce::Thread::signalThreadShouldExit ( )
inherited

Sets a flag to tell the thread it should stop.

Calling this means that the threadShouldExit() method will then return true. The thread should be regularly checking this to see whether it should exit.

If your thread makes use of wait(), you might want to call notify() after calling this method, to interrupt any waits that might be in progress, and allow it to reach a point where it can exit.

See also
threadShouldExit, waitForThreadToExit

Referenced by juce::detail::MessageThread::stop().

◆ sleep()

void juce::Thread::sleep ( int  milliseconds)
staticinherited

Suspends the execution of the current thread until the specified timeout period has elapsed (note that this may not be exact).

The timeout period must not be negative and whilst sleeping the thread cannot be woken up so it should only be used for short periods of time and when other methods such as using a WaitableEvent or CriticalSection are not possible.

Referenced by juce::OpenGLContext::NativeContext::getNativeWindowFromSurfaceHolder(), juce::detail::MessageThread::run(), and juce::OpenGLContext::NativeContext::swapBuffers().

◆ startRealtimeThread()

bool juce::Thread::startRealtimeThread ( const RealtimeOptions options)
inherited

Starts the thread with realtime performance characteristics on platforms that support it.

You cannot change the options of a running realtime thread, nor switch a non-realtime thread to a realtime thread. To make these changes you must first stop the thread and then restart with different options.

Parameters
optionsRealtime options the thread should be created with.
See also
startThread, RealtimeOptions

◆ startThread() [1/2]

bool juce::Thread::startThread ( )
inherited

Attempts to start a new thread with default ('Priority::normal') priority.

This will cause the thread's run() method to be called by a new thread. If this thread is already running, startThread() won't do anything.

If a thread cannot be created with the requested priority, this will return false and Thread::run() will not be called. An exception to this is the Android platform, which always starts a thread and attempts to upgrade the thread after creation.

Returns
true if the thread started successfully. false if it was unsuccessful.
See also
stopThread

Referenced by juce::detail::MessageThread::start().

◆ startThread() [2/2]

bool juce::Thread::startThread ( Priority  newPriority)
inherited

Attempts to start a new thread with a given priority.

This will cause the thread's run() method to be called by a new thread. If this thread is already running, startThread() won't do anything.

If a thread cannot be created with the requested priority, this will return false and Thread::run() will not be called. An exception to this is the Android platform, which always starts a thread and attempts to upgrade the thread after creation.

Parameters
newPriorityPriority the thread should be assigned. This parameter is ignored on Linux.
Returns
true if the thread started successfully, false if it was unsuccesful.
See also
startThread, setPriority, startRealtimeThread

◆ startThreadInternal()

bool juce::Thread::startThreadInternal ( Priority  )
privateinherited

◆ startTimer()

void juce::Timer::startTimer ( int  intervalInMilliseconds)
noexceptinherited

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.

Parameters
intervalInMillisecondsthe interval to use (any value less than 1 will be rounded up to 1)

Referenced by juce::detail::MouseInputSourceList::beginDragAutoRepeat(), juce::detail::TopLevelWindowManager::checkFocus(), juce::detail::TopLevelWindowManager::checkFocusAsync(), juce::StandalonePluginHolder::init(), and juce::DeviceChangeDetector::triggerAsyncDeviceChangeCallback().

◆ startTimerHz()

void juce::Timer::startTimerHz ( int  timerFrequencyHz)
noexceptinherited

Starts the timer with an interval specified in Hertz.

This is effectively the same as calling startTimer (1000 / timerFrequencyHz).

Referenced by juce::AnimatedPosition< Behaviour >::endDrag(), juce::AnimatedPosition< Behaviour >::nudge(), and juce::AnimatedPosition< Behaviour >::timerCallback().

◆ stopThread()

bool juce::Thread::stopThread ( int  timeOutMilliseconds)
inherited

Attempts to stop the thread running.

This method will cause the threadShouldExit() method to return true and call notify() in case the thread is currently waiting.

Hopefully the thread will then respond to this by exiting cleanly, and the stopThread method will wait for a given time-period for this to happen.

If the thread is stuck and fails to respond after the timeout, it gets forcibly killed, which is a very bad thing to happen, as it could still be holding locks, etc. which are needed by other parts of your program.

Parameters
timeOutMillisecondsThe number of milliseconds to wait for the thread to finish before killing it by force. A negative value in here will wait forever.
Returns
true if the thread was cleanly stopped before the timeout, or false if it had to be killed by force.
See also
signalThreadShouldExit, threadShouldExit, waitForThreadToExit, isThreadRunning

Referenced by juce::detail::MessageThread::stop().

◆ stopTimer()

void juce::Timer::stopTimer ( )
noexceptinherited

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.

Referenced by juce::StandalonePluginHolder::~StandalonePluginHolder(), juce::AnimatedPosition< Behaviour >::beginDrag(), juce::detail::MouseInputSourceList::beginDragAutoRepeat(), juce::AnimatedPosition< Behaviour >::setPosition(), juce::DeviceChangeDetector::timerCallback(), juce::detail::MouseInputSourceList::timerCallback(), and juce::AnimatedPosition< Behaviour >::timerCallback().

◆ threadComplete()

virtual void juce::ThreadWithProgressWindow::threadComplete ( bool  userPressedCancel)
virtual

This method is called (on the message thread) when the operation has finished.

You may choose to use this callback to delete the ThreadWithProgressWindow object.

◆ threadEntryPoint()

void juce::Thread::threadEntryPoint ( )
privateinherited

◆ threadShouldExit()

bool juce::Thread::threadShouldExit ( ) const
inherited

Checks whether the thread has been told to stop running.

Threads need to check this regularly, and if it returns true, they should return from their run() method at the first possible opportunity.

See also
signalThreadShouldExit, currentThreadShouldExit

Referenced by juce::detail::MessageThread::run().

◆ timerCallback()

void juce::ThreadWithProgressWindow::timerCallback ( )
overrideprivatevirtual

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.

Implements juce::Timer.

◆ wait()

bool juce::Thread::wait ( double  timeOutMilliseconds) const
inherited

Suspends the execution of this thread until either the specified timeout period has elapsed, or another thread calls the notify() method to wake it up.

A negative timeout value means that the method will wait indefinitely.

Returns
true if the event has been signalled, false if the timeout expires.

◆ waitForThreadToExit()

bool juce::Thread::waitForThreadToExit ( int  timeOutMilliseconds) const
inherited

Waits for the thread to stop.

This will wait until isThreadRunning() is false or until a timeout expires.

Parameters
timeOutMillisecondsthe time to wait, in milliseconds. If this value is less than zero, it will wait forever.
Returns
true if the thread exits, or false if the timeout expires first.

◆ yield()

void juce::Thread::yield ( )
staticinherited

Yields the current thread's CPU time-slot and allows a new thread to run.

If there are no other threads of equal or higher priority currently running then this will return immediately and the current thread will continue to run.

Member Data Documentation

◆ affinityMask

uint32 juce::Thread::affinityMask = 0
privateinherited

◆ alertWindow

std::unique_ptr<AlertWindow> juce::ThreadWithProgressWindow::alertWindow
private

◆ defaultEvent

WaitableEvent juce::Thread::defaultEvent
privateinherited

◆ deleteOnThreadEnd

bool juce::Thread::deleteOnThreadEnd = false
privateinherited

◆ listeners

ThreadSafeListenerList<Listener> juce::Thread::listeners
privateinherited

◆ message

String juce::ThreadWithProgressWindow::message
private

◆ messageLock

CriticalSection juce::ThreadWithProgressWindow::messageLock
private

◆ osDefaultStackSize

constexpr size_t juce::Thread::osDefaultStackSize { 0 }
staticconstexprinherited

◆ positionInQueue

size_t juce::Timer::positionInQueue = (size_t) -1
privateinherited

◆ priority

std::atomic<Priority> juce::Thread::priority
privateinherited

◆ progress

double juce::ThreadWithProgressWindow::progress
private

◆ realtimeOptions

std::optional<RealtimeOptions> juce::Thread::realtimeOptions = {}
privateinherited

◆ shouldExit

std::atomic<bool> juce::Thread::shouldExit { false }
privateinherited

◆ startStopLock

CriticalSection juce::Thread::startStopLock
privateinherited

◆ startSuspensionEvent

WaitableEvent juce::Thread::startSuspensionEvent
privateinherited

◆ threadHandle

std::atomic<void*> juce::Thread::threadHandle { nullptr }
privateinherited

◆ threadId

std::atomic<ThreadID> juce::Thread::threadId { nullptr }
privateinherited

◆ threadName

const String juce::Thread::threadName
privateinherited

◆ threadStackSize

size_t juce::Thread::threadStackSize
privateinherited

◆ timeOutMsWhenCancelling

const int juce::ThreadWithProgressWindow::timeOutMsWhenCancelling
private

◆ timerPeriodMs

int juce::Timer::timerPeriodMs = 0
privateinherited

◆ timerThread

SharedResourcePointer<TimerThread> juce::Timer::timerThread
privateinherited

◆ wasCancelledByUser

bool juce::ThreadWithProgressWindow::wasCancelledByUser
private

The documentation for this class was generated from the following file: