added QSE::ThreadR and QSE::ThreadC
This commit is contained in:
@ -49,29 +49,6 @@ Thread::~Thread () QSE_CPP_NOEXCEPT
|
||||
qse_thr_fini (this);
|
||||
}
|
||||
|
||||
int Thread::thr_func_call_rtn (qse_thr_t* thr, void* ctx)
|
||||
{
|
||||
// 'thr' may not be point to the actual Thread
|
||||
// for the reason stated in Thread::start().
|
||||
// utilize the ctx pointer passed in Thread::start().
|
||||
Thread* t = (Thread*)ctx;
|
||||
return t->__tmprtn(t);
|
||||
}
|
||||
|
||||
int Thread::start (ThreadRoutine rtn, int flags) QSE_CPP_NOEXCEPT
|
||||
{
|
||||
if (this->__state == QSE_THR_RUNNING) return -1;
|
||||
|
||||
// this != (qse_thr_t*)this may not be equal if this class
|
||||
// has some internal added data fields. e.g. it contains
|
||||
// a virtual function. direct invocation without the extra ctx pointer
|
||||
// like this has some implications when attempting to convert
|
||||
// qse_thr_t* to Thread*.
|
||||
// qse_thr_start (this, (qse_thr_rtn_t)rtn, QSE_NULL, flags);
|
||||
// so i pass a void pointer 'this' as the third argument.
|
||||
this->__tmprtn = rtn;
|
||||
return qse_thr_start(this, thr_func_call_rtn, this, flags);
|
||||
}
|
||||
|
||||
static int thr_func_call_main (qse_thr_t* thr, void* ctx)
|
||||
{
|
||||
@ -93,4 +70,29 @@ int Thread::stop () QSE_CPP_NOEXCEPT
|
||||
return qse_thr_stop(this);
|
||||
}
|
||||
|
||||
|
||||
int ThreadR::thr_func_call_rtn (qse_thr_t* thr, void* ctx)
|
||||
{
|
||||
// 'thr' may not be point to the actual Thread
|
||||
// for the reason stated in Thread::start().
|
||||
// utilize the ctx pointer passed in Thread::start().
|
||||
ThreadR* t = (ThreadR*)ctx;
|
||||
return t->__tmprtn(t);
|
||||
}
|
||||
|
||||
int ThreadR::start (ThreadRoutine rtn, int flags) QSE_CPP_NOEXCEPT
|
||||
{
|
||||
if (this->__state == QSE_THR_RUNNING) return -1;
|
||||
|
||||
// this != (qse_thr_t*)this may not be equal if this class
|
||||
// has some internal added data fields. e.g. it contains
|
||||
// a virtual function. direct invocation without the extra ctx pointer
|
||||
// like this has some implications when attempting to convert
|
||||
// qse_thr_t* to Thread*.
|
||||
// qse_thr_start (this, (qse_thr_rtn_t)rtn, QSE_NULL, flags);
|
||||
// so i pass a void pointer 'this' as the third argument.
|
||||
this->__tmprtn = rtn;
|
||||
return qse_thr_start(this, thr_func_call_rtn, this, flags);
|
||||
}
|
||||
|
||||
QSE_END_NAMESPACE(QSE)
|
||||
|
@ -113,7 +113,7 @@ static void* __thread_main (void* arg)
|
||||
qse_thr_blockallsigs (thr);
|
||||
else
|
||||
qse_thr_unblockallsigs (thr);
|
||||
|
||||
|
||||
while (thr->__state != QSE_THR_RUNNING)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
|
Reference in New Issue
Block a user