void *MThread_helper( void *arg ) { MThread *me; me=(MThread *)arg; return( me->Run() ); }
static void *thread_start_routine (void *arg) { MThread *newthr = (MThread *)arg; pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, NULL); newthr->routine (newthr->arg); return NULL; }
static DWORD WINAPI thread_start_routine (void *arg) //static void thread_start_routine (void *arg) { MThread *newthr = (MThread *)arg; newthr->id = GetCurrentThreadId (); newthr->routine (newthr->arg); return 0; }
void* MThread::ThreadFunction(void* aPtr) { MThread* pThrd = reinterpret_cast<MThread*>(aPtr); if (pThrd) pThrd->Run(); return NULL; };
MThread *MThread::Start (void (*routine) (void *arg), void *arg) { MThread *newthr = new MThread (); newthr->routine = routine; newthr->arg = arg; int rc = pthread_create (&newthr->tid, NULL, thread_start_routine, newthr); if (rc) { newthr->DecRef (); return NULL; } return newthr; }
MThread *MThread::Start (void (*routine) (void *arg), void *arg) { DWORD dwtid; MThread *newthr = new MThread (); newthr->routine = routine; newthr->arg = arg; newthr->th = CreateThread (NULL, WIN32_THREAD_STACK_SIZE, thread_start_routine, newthr, 0, &dwtid); //newthr->th = (HANDLE)_beginthread(thread_start_routine, 0, newthr); if (!newthr->th) { newthr->DecRef (); return NULL; } return newthr; }
void* worker(void* arg){ MThread* threadObj = (MThread*)arg; threadObj->run(); threadObj->threadId = 0; return NULL; }
bool is_current_thread(MThread &thread) { return QThread::currentThread() == thread.qthread(); }