#include <AsyncFw/MainThread>
#include <AsyncFw/Log>
int main(int argc, char *argv[]) {
logDebug() <<
"Main id:" << _mainThread->
id();
logDebug() <<
"T1 id:" << thread1.
id();
logDebug() <<
"T2 id:" << thread2.
id();
logInfo() <<
"run in thread" << ct->
name() << ct->
id();
std::this_thread::sleep_for(std::chrono::milliseconds(10));
logInfo() <<
"run in thread" << ct->
name() << ct->
id();
std::this_thread::sleep_for(std::chrono::milliseconds(10));
logInfo() <<
"run in thread" << ct->
name() << ct->
id();
std::this_thread::sleep_for(std::chrono::milliseconds(10));
logInfo() << "exit application";
AsyncFw::MainThread::exit(0);
});
});
});
logNotice() << "Start Applicaiton";
int ret = AsyncFw::MainThread::exec();
logNotice() << "End Applicaiton";
return ret;
}
The AbstractThread class provides the base functionality for thread management.
Definition AbstractThread.h:45
std::string name() const
Returns name of managed thread.
Definition AbstractThread.cpp:679
std::thread::id id() const
Returns unique identifier of managed thread.
Definition AbstractThread.cpp:677
std::enable_if< std::is_void< typenamestd::invoke_result< M >::type >::value, bool >::type invokeMethod(M method, bool sync=false) const
Runs a method in a managed thread.
Definition AbstractThread.h:79
static AbstractThread * currentThread()
Returns a pointer to the AsyncFw::AbstractThread that manages the currently executing thread.
Definition AbstractThread.cpp:297
void start()
Create a managed thread and run exec().
Definition AbstractThread.cpp:642
AsyncFw::Thread thread with sockets.
Definition Thread.h:16