Skip to content

Commit

Permalink
Isolated none-existing posix threading functions on Android
Browse files Browse the repository at this point in the history
  • Loading branch information
sgeto committed Mar 3, 2017
1 parent 82ed99b commit 4e25f08
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion qtools/qthread_unix.cpp
Expand Up @@ -76,14 +76,18 @@ QThreadPrivate::~QThreadPrivate()

void *QThreadPrivate::start(void *arg)
{
#ifndef __ANDROID__
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
#endif
pthread_cleanup_push(QThreadPrivate::finish, arg);

QThread *thr = reinterpret_cast<QThread *>(arg);

thr->started();
#ifndef __ANDROID__
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
pthread_testcancel();
#endif
thr->run();

pthread_cleanup_pop(1);
Expand Down Expand Up @@ -132,7 +136,9 @@ void QThread::start()
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_DETACHED);
#ifndef __ANDROID__
pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);
#endif
if (d->stackSize>0)
{
#if defined(_POSIX_THREAD_ATTR_STACKSIZE) && (_POSIX_THREAD_ATTR_STACKSIZE-0>0)
Expand Down Expand Up @@ -160,7 +166,7 @@ void QThread::start()
void QThread::terminate()
{
QMutexLocker locker(&d->mutex);

#ifndef __ANDROID__
if (!d->thread_id) return;

int code = pthread_cancel(d->thread_id);
Expand All @@ -172,6 +178,7 @@ void QThread::terminate()
{
d->terminated = TRUE;
}
#endif
}

void QThread::wait()
Expand Down

0 comments on commit 4e25f08

Please sign in to comment.