AThread#
Represents a user-defined thread.
Header: | #include <AUI/Thread/AThread.h> |
CMake: | aui_link(my_target PUBLIC aui::core) |
Public Types#
Interrupted#
class AThread::Interrupted
Exception that is thrown by AThread::interruptionPoint()
, if interruption is requested for
this thread. Handled by AThread::start
.
Empty structure.
Public Methods#
current#
static const _<AAbstractThread>& AThread::current()
- Returns
- current thread.
Examples#
examples/app/game_of_life/src/main.cpp
Game of Life - Game of Life implementation that uses advanced large dynamic data rendering techniques such as ITexture, AImage to be GPU friendly. The computation is performed in AThreadPool.
examples/ui/contacts/src/view/ContactDetailsView.cpp
AUI Contacts - Usage of AUI_DECLARATIVE_FOR to make a contacts-like application.
return;
}
// discard
if (AMessageBox::show(dynamic_cast<AWindow*>(AWindow::current()), "Do you really want to discard?", "This action is irreversible!", AMessageBox::Icon::NONE, AMessageBox::Button::YES_NO) != AMessageBox::ResultButton::YES) {
return;
}
mContact = mOriginalContact;
mEditorMode = false;
}
examples/7guis/cells/src/Spreadsheet.h
7GUIs Cells - Spreadsheet processor (Excel).
examples/7guis/circle_drawer/src/main.cpp
7GUIs Circle Drawer - Undo, redo, dialog control.
[this, circle] {
auto radiusPopup = _new<AWindow>(
"", 200_dp, 50_dp, dynamic_cast<AWindow*>(AWindow::current()), WindowStyle::MODAL);
radiusPopup->setContents(Vertical {
Label { "Adjust diameter of circle at {}."_format(circle->position) },
_new<ASlider>() AUI_LET {
it->setValue(circle->radius / MAX_RADIUS);
connect(
interruptionPoint#
Interruption point
If the interruption flag is raised for the caller thread then flag is reset and AThread::Interrupted exception is thrown, efficiently stopping the task execution and safely freeing resources with C++'s RAII feature.
AUI_THREADPOOL, AUI_THREADPOOL_X, AThreadPool::enqueue, AUI_ENTRY handle AThread::Interrupted, so throwing AThread::Interrupted is safe.
join#
Waits for thread to be finished.
main#
static const _<AAbstractThread>& AThread::main()
Returns main thread of the application.
processMessages#
Processes messages from other threads of current thread. Called by framework itself using IEventLoop.
setName#
static void AThread::setName(AString name)
- Arguments
name
new name of the thread
Sets name of the current thread for debugger.
sleep#
Sleep for specified duration.
Most operation systems guarantee that elasped time will be greater than specified.
AThread::interrupt()
is supported.
- Arguments
duration
sleep duration.
start#
Start thread execution.