![]() |
ATLAS Offline Software
|
Helper class to manage a long-running thread (duration of event loop). More...
#include <EventLoopUtils.h>
Public Member Functions | |
| LoopThread (std::function< void()> &&callback, int callbackInterval=-1) | |
| ~LoopThread () | |
| LoopThread (const LoopThread &)=delete | |
| LoopThread (LoopThread &&)=delete | |
| LoopThread & | operator= (const LoopThread &)=delete |
| LoopThread & | operator= (LoopThread &&)=delete |
| void | start () |
| Keep notifying the thread until the callback is called for the first time (returns just before calling the callback). | |
| void | stop () |
| Flag the main loop to finish. | |
| void | wait () |
| Wait until main loop finishes. | |
| std::condition_variable & | cond () |
| std::mutex & | mutex () |
Private Member Functions | |
| void | waitForCond (std::unique_lock< std::mutex > &lock) |
| Helper to wait for the condition. | |
| void | run () |
| Main function executed by the thread. | |
Private Attributes | |
| std::condition_variable | m_cond |
| Condition for which the thread waits most of its lifetime. | |
| std::mutex | m_mutex |
| Mutex used to notify the condition. | |
| std::atomic< bool > | m_keepRunning {true} |
| The thread's inner while-loop condition variable. | |
| std::atomic< bool > | m_started {false} |
| Flag whether the main loop of the thread has started and will listen to further notifications. | |
| std::atomic< bool > | m_finished {false} |
| Flag whether the main loop of the thread has finished. | |
| std::function< void()> | m_callback |
| The callback executed in each step of the thread's inner while-loop. | |
| int | m_callbackIntervalMilliseconds {-1} |
| If positive, call the callback periodically with this interval regardless of the m_cond. | |
| std::unique_ptr< std::thread > | m_thread |
| The thread object. | |
Helper class to manage a long-running thread (duration of event loop).
Definition at line 16 of file EventLoopUtils.h.
|
inlineexplicit |
Definition at line 63 of file EventLoopUtils.h.
|
inline |
Definition at line 68 of file EventLoopUtils.h.
|
delete |
|
delete |
|
inline |
Definition at line 106 of file EventLoopUtils.h.
|
inline |
Definition at line 107 of file EventLoopUtils.h.
|
delete |
|
delete |
|
inlineprivate |
Main function executed by the thread.
Definition at line 45 of file EventLoopUtils.h.
|
inline |
Keep notifying the thread until the callback is called for the first time (returns just before calling the callback).
Definition at line 80 of file EventLoopUtils.h.
|
inline |
Flag the main loop to finish.
Definition at line 88 of file EventLoopUtils.h.
|
inline |
Wait until main loop finishes.
Definition at line 94 of file EventLoopUtils.h.
|
inlineprivate |
Helper to wait for the condition.
Definition at line 36 of file EventLoopUtils.h.
|
private |
The callback executed in each step of the thread's inner while-loop.
Definition at line 29 of file EventLoopUtils.h.
|
private |
If positive, call the callback periodically with this interval regardless of the m_cond.
Definition at line 31 of file EventLoopUtils.h.
|
private |
Condition for which the thread waits most of its lifetime.
Definition at line 19 of file EventLoopUtils.h.
|
private |
Flag whether the main loop of the thread has finished.
Definition at line 27 of file EventLoopUtils.h.
|
private |
The thread's inner while-loop condition variable.
Definition at line 23 of file EventLoopUtils.h.
|
private |
Mutex used to notify the condition.
Definition at line 21 of file EventLoopUtils.h.
|
private |
Flag whether the main loop of the thread has started and will listen to further notifications.
Definition at line 25 of file EventLoopUtils.h.
|
private |
The thread object.
Definition at line 33 of file EventLoopUtils.h.