renamed ThreadC to ThreadF

This commit is contained in:
hyung-hwan 2018-01-29 05:02:51 +00:00
parent 57201a2af3
commit 8e78356337
2 changed files with 13 additions and 13 deletions

View File

@ -114,24 +114,24 @@ protected:
}; };
template <typename F> template <typename F>
class ThreadC: public Thread class ThreadF: public Thread
{ {
public: public:
ThreadC () {} ThreadF () {}
ThreadC (const F& f): __lfunc(f) {} ThreadF (const F& f): __lfunc(f) {}
#if defined(QSE_CPP_ENABLE_CPP11_MOVE) #if defined(QSE_CPP_ENABLE_CPP11_MOVE)
ThreadC (F&& f): __lfunc(QSE_CPP_RVREF(f)) {} ThreadF (F&& f): __lfunc(QSE_CPP_RVREF(f)) {}
#endif #endif
static int call_func (qse_thr_t* thr, void* ctx) static int call_func (qse_thr_t* thr, void* ctx)
{ {
ThreadC<F>* t = (ThreadC<F>*)ctx; ThreadF<F>* t = (ThreadF<F>*)ctx;
return t->__lfunc (t); return t->__lfunc (t);
} }
int start (int flags = 0) QSE_CPP_NOEXCEPT int start (int flags = 0) QSE_CPP_NOEXCEPT
{ {
return qse_thr_start (this, (qse_thr_rtn_t)ThreadC<F>::call_func, this, flags); return qse_thr_start (this, (qse_thr_rtn_t)ThreadF<F>::call_func, this, flags);
} }
protected: protected:
@ -142,12 +142,12 @@ protected:
#if 0 #if 0
// i don't want to use std::function. // i don't want to use std::function.
class ThreadC: public Thread class ThreadF: public Thread
{ {
public: public:
static int call_func (qse_thr_t* thr, void* ctx) static int call_func (qse_thr_t* thr, void* ctx)
{ {
ThreadC* t = (ThreadC*)ctx; ThreadF* t = (ThreadF*)ctx;
return t->__lfunc (t); return t->__lfunc (t);
} }
@ -155,11 +155,11 @@ public:
int start (X&& f, int flags) QSE_CPP_NOEXCEPT int start (X&& f, int flags) QSE_CPP_NOEXCEPT
{ {
this->__lfunc = QSE_CPP_RVREF(f); this->__lfunc = QSE_CPP_RVREF(f);
return qse_thr_start (this, (qse_thr_rtn_t)ThreadC::call_func, this, flags); return qse_thr_start (this, (qse_thr_rtn_t)ThreadF::call_func, this, flags);
} }
protected: protected:
std::function<int(ThreadC*)> __lfunc; std::function<int(ThreadF*)> __lfunc;
}; };
#endif #endif

View File

@ -141,7 +141,7 @@ static int test1 (void)
} }
#if (__cplusplus >= 201103L) || (defined(_MSC_VER) && _MSC_VER >= 1900) //C++11 or later #if (__cplusplus >= 201103L) || (defined(_MSC_VER) && _MSC_VER >= 1900) //C++11 or later
QSE::ThreadC<decltype(lambda)> thr3 (lambda); QSE::ThreadF<decltype(lambda)> thr3 (lambda);
thr3.setStackSize (64000); thr3.setStackSize (64000);
thr3.setContext (&localstopreq); thr3.setContext (&localstopreq);
if (thr3.start(QSE::Thread::SIGNALS_BLOCKED) <= -1) if (thr3.start(QSE::Thread::SIGNALS_BLOCKED) <= -1)
@ -151,7 +151,7 @@ static int test1 (void)
} }
// turn a lambda with capture to a thread // turn a lambda with capture to a thread
QSE::ThreadC<decltype(lambda_with_capture)> thr4 (lambda_with_capture); QSE::ThreadF<decltype(lambda_with_capture)> thr4 (lambda_with_capture);
thr4.setStackSize (64000); thr4.setStackSize (64000);
if (thr4.start(QSE::Thread::SIGNALS_BLOCKED) <= -1) if (thr4.start(QSE::Thread::SIGNALS_BLOCKED) <= -1)
{ {
@ -161,7 +161,7 @@ static int test1 (void)
#endif #endif
// turn a functor to a thread // turn a functor to a thread
QSE::ThreadC<Functor> thr5; QSE::ThreadF<Functor> thr5;
thr5.setStackSize (64000); thr5.setStackSize (64000);
thr5.setContext (&localstopreq); thr5.setContext (&localstopreq);
if (thr5.start(QSE::Thread::SIGNALS_BLOCKED) <= -1) if (thr5.start(QSE::Thread::SIGNALS_BLOCKED) <= -1)