7 #include <core/Thread.h>
9 #include <tasking/Runnable.h>
13 #ifndef USE_CUSTOM_EVENT
14 #include <condition_variable>
38 public std::enable_shared_from_this<ThreadRunnable>
60 static std::shared_ptr<ThreadRunnable>
66 std::shared_ptr<ThreadRunnable> result( th );
90 bool join(
unsigned int millis = 0xFFFFFFFF );
91 bool setAffinity( uint64_t aff )
93 return mThread->setAffinity( aff );
117 EThreadState getState()
const {
return mState; }
119 bool getTerminateRequest() {
return mEnd; }
130 std::unique_ptr<Thread> mThread;
131 #ifdef USE_CUSTOM_EVENT
134 volatile bool mSignaled;
135 std::condition_variable mWaitForTasksCond;
143 _processAwaken( std::shared_ptr<Process> p );
150 _suspendInternal( uint64_t millis,
Process* proc ) noexcept;
151 void _signalWakeup();
187 void onPostTask( std::shared_ptr<Process> process )
override;
Wrapper around std::thread to prive more abstractions.
Definition: Thread.h:33
A periodic task, implementing a microthread.
Definition: Process.h:107
A class representing a "running" task, with added functionality to post events requesting execution o...
Definition: Runnable.h:183
Thread with Runnable behaviour.
Definition: ThreadRunnable.h:40
void start()
Start Thread Internally calls Runnablle::processTask in an infinite loop, with some other check for p...
ThreadRunnable(Runnable::RunnableCreationOptions opts=sDefaultOpts)
Create a thread with an empty loop, that continuosly processes posted tasks.
static ThreadRunnable * getCurrentThreadRunnable()
bool join(unsigned int millis=0xFFFFFFFF)
Does a join on the underlying Thread.
virtual void onThreadStart()
Called one time at the start of the thread loop, so, already in this thread context Don't confuse wit...
Definition: ThreadRunnable.h:171
virtual void onThreadEnd()
Called when at the end of the thread loop.
Definition: ThreadRunnable.h:176
static std::shared_ptr< ThreadRunnable > create(bool autoRun=true, Runnable::RunnableCreationOptions opts=sDefaultOpts)
Create new ThreadRunnable.
Definition: ThreadRunnable.h:61
virtual void onJoined()
Called by join() when done.
Definition: ThreadRunnable.h:181
void onPostTask(std::shared_ptr< Process > process) override
virtual void onStart()
Called by start() function Children can override it to add custom behaviour.
Definition: ThreadRunnable.h:164
ECallbackResult
Type resturned by callbacks subscribed to CallbackSubscriptors.
Definition: CallbackSubscriptor.h:32
EGenericProcessResult
Result from functor used in a GenericProcess.
Definition: GenericProcessDefs.h:14
Definition: Callback_Impl.h:11
Definition: Runnable.h:195