15#include "AUI/Common/ADeque.h"
17#include "AUI/Common/SharedPtrTypes.h"
18#include "AUI/Common/AString.h"
19#include "AUI/Util/AMessageQueue.h"
20#include <AUI/Platform/AStacktrace.h>
37 friend void setupUIThread()
noexcept;
43 typedef std::thread::id
id;
57 void enqueue(AMessageQueue<>::Message f);
64 virtual bool isInterrupted();
69 virtual void resetInterruptFlag();
77 virtual void interrupt();
84 return mCurrentEventLoop;
93 template <
class Callable>
103 template <
class Callable>
110 const AString& threadName() const noexcept {
121 bool messageQueueEmpty() noexcept;
134 void updateThreadName() noexcept;
135 virtual
void processMessagesImpl();
167#include "AUI/Common/AObject.h"
197 std::thread* mThread =
nullptr;
204 std::function<void()> mFunctor;
209 std::atomic_bool mInterrupted =
false;
213 AThread(std::function<
void()> functor);
231 static void sleep(std::chrono::milliseconds duration);
247 static void interruptionPoint();
256 auto cur = current();
257 cur->mThreadName = std::move(name);
258 cur->updateThreadName();
265 current()->processMessagesImpl();
268 bool isInterrupted()
override;
269 void resetInterruptFlag()
override;
270 void interrupt()
override;
279#include "AConditionVariable.h"
Represents an abstract thread. Not all threads are created through AThread - these are interfaced wit...
Definition: AThread.h:33
void operator*(Callable fun)
Enqueue message to make. Helper function for async, asyncX, ui, uiX.
Definition: AThread.h:104
IEventLoop * getCurrentEventLoop() const
Get current event loop for this thread.
Definition: AThread.h:83
void operator<<(Callable fun)
Enqueue message to make.
Definition: AThread.h:94
std::thread::id id
Thread ID type.
Definition: AThread.h:43
Represents a condition variable.
Definition: AConditionVariable.h:24
Universal thread-safe message (callback) queue implementation.
Definition: AMessageQueue.h:29
A base object class.
Definition: AObject.h:49
Stacktrace consisting of a collection of stack function frames.
Definition: AStacktrace.h:28
Represents a Unicode character string.
Definition: AString.h:37
Exception that is thrown by AThread::interruptionPoint(), if interruption is requested for this threa...
Definition: AThread.h:181
void needRethrow() const noexcept
Schedules AThread::Interrupted exception to the next interruption point. Sometimes you could not thro...
Definition: AThread.h:188
Represents a user-defined thread.
Definition: AThread.h:174
static _< AAbstractThread > current()
Definition: AThread.cpp:221
static void setName(AString name) noexcept
Definition: AThread.h:255
static void processMessages()
Processes messages from other threads of current thread. Called by framework itself using IEventLoop.
Definition: AThread.h:264
Definition: IEventLoop.h:17
An std::weak_ptr with AUI extensions.
Definition: SharedPtrTypes.h:177
Basic syscall-based synchronization primitive.
Definition: AMutex.h:33