本文整理汇总了C++中QThread::d_func方法的典型用法代码示例。如果您正苦于以下问题:C++ QThread::d_func方法的具体用法?C++ QThread::d_func怎么用?C++ QThread::d_func使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QThread
的用法示例。
在下文中一共展示了QThread::d_func方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: finish
void QThreadPrivate::finish(void *arg)
{
QThread *thr = reinterpret_cast<QThread *>(arg);
QThreadPrivate *d = thr->d_func();
QMutexLocker locker(&d->mutex);
d->priority = QThread::InheritPriority;
d->running = false;
d->finished = true;
if (d->terminated)
emit thr->terminated();
d->terminated = false;
emit thr->finished();
if (d->data->eventDispatcher) {
d->data->eventDispatcher->closingDown();
QAbstractEventDispatcher *eventDispatcher = d->data->eventDispatcher;
d->data->eventDispatcher = 0;
delete eventDispatcher;
}
void *data = &d->data->tls;
QThreadStorageData::finish((void **)data);
d->thread_id = 0;
d->thread_done.wakeAll();
}
示例2: QAdoptedThread
QThreadData *QThreadData::current()
{
QThreadData *data = get_thread_data();
if (!data) {
void *a;
if (QInternal::activateCallbacks(QInternal::AdoptCurrentThread, &a)) {
QThread *adopted = static_cast<QThread*>(a);
Q_ASSERT(adopted);
data = QThreadData::get2(adopted);
set_thread_data(data);
adopted->d_func()->running = true;
adopted->d_func()->finished = false;
static_cast<QAdoptedThread *>(adopted)->init();
} else {
data = new QThreadData;
QT_TRY {
set_thread_data(data);
data->thread = new QAdoptedThread(data);
} QT_CATCH(...) {
clear_thread_data();
data->deref();
data = 0;
QT_RETHROW;
}
data->deref();
}
示例3: QAdoptedThread
QThreadData *QThreadData::current()
{
pthread_once(¤t_thread_data_once, create_current_thread_data_key);
QThreadData *data = reinterpret_cast<QThreadData *>(pthread_getspecific(current_thread_data_key));
if (!data) {
void *a;
if (QInternal::activateCallbacks(QInternal::AdoptCurrentThread, &a)) {
QThread *adopted = static_cast<QThread*>(a);
Q_ASSERT(adopted);
data = QThreadData::get2(adopted);
pthread_setspecific(current_thread_data_key, data);
adopted->d_func()->running = true;
adopted->d_func()->finished = false;
static_cast<QAdoptedThread *>(adopted)->init();
} else {
data = new QThreadData;
pthread_setspecific(current_thread_data_key, data);
data->thread = new QAdoptedThread(data);
data->deref();
}
(void) q_atomic_test_and_set_ptr(&QCoreApplicationPrivate::theMainThread, 0, data->thread);
}
return data;
}
示例4: TlsSetValue
/*
QThreadData
*/
QThreadData *QThreadData::current()
{
qt_create_tls();
QThreadData *threadData = reinterpret_cast<QThreadData *>(TlsGetValue(qt_current_thread_data_tls_index));
if (!threadData) {
QThread *adopted = 0;
if (QInternal::activateCallbacks(QInternal::AdoptCurrentThread, (void **) &adopted)) {
Q_ASSERT(adopted);
threadData = QThreadData::get2(adopted);
TlsSetValue(qt_current_thread_data_tls_index, threadData);
adopted->d_func()->running = true;
adopted->d_func()->finished = false;
static_cast<QAdoptedThread *>(adopted)->init();
} else {
threadData = new QThreadData;
// This needs to be called prior to new AdoptedThread() to
// avoid recursion.
TlsSetValue(qt_current_thread_data_tls_index, threadData);
QT_TRY {
threadData->thread = new QAdoptedThread(threadData);
} QT_CATCH(...) {
TlsSetValue(qt_current_thread_data_tls_index, 0);
threadData->deref();
threadData = 0;
QT_RETHROW;
}
threadData->deref();
}
示例5: TlsSetValue
/*
QThreadData
*/
QThreadData *QThreadData::current()
{
qt_create_tls();
QThreadData *threadData = reinterpret_cast<QThreadData *>(TlsGetValue(qt_current_thread_data_tls_index));
if (!threadData) {
QThread *adopted = 0;
if (QInternal::activateCallbacks(QInternal::AdoptCurrentThread, (void **) &adopted)) {
Q_ASSERT(adopted);
threadData = QThreadData::get2(adopted);
TlsSetValue(qt_current_thread_data_tls_index, threadData);
adopted->d_func()->running = true;
adopted->d_func()->finished = false;
static_cast<QAdoptedThread *>(adopted)->init();
} else {
threadData = new QThreadData;
// This needs to be called prior to new AdoptedThread() to
// avoid recursion.
TlsSetValue(qt_current_thread_data_tls_index, threadData);
threadData->thread = new QAdoptedThread(threadData);
threadData->deref();
}
if (!QCoreApplicationPrivate::theMainThread) {
QCoreApplicationPrivate::theMainThread = threadData->thread;
} else {
HANDLE realHandle = INVALID_HANDLE_VALUE;
#if !defined(Q_OS_WINCE) || (defined(_WIN32_WCE) && (_WIN32_WCE>=0x600))
DuplicateHandle(GetCurrentProcess(),
GetCurrentThread(),
GetCurrentProcess(),
&realHandle,
0,
FALSE,
DUPLICATE_SAME_ACCESS);
#else
realHandle = (HANDLE)GetCurrentThreadId();
#endif
qt_watch_adopted_thread(realHandle, threadData->thread);
}
}
return threadData;
}
示例6: TlsSetValue
/*
QThreadData
*/
QThreadData *QThreadData::current()
{
qt_create_tls();
QThreadData *threadData = reinterpret_cast<QThreadData *>(TlsGetValue(qt_current_thread_data_tls_index));
if (!threadData) {
QThread *adopted = 0;
if (QInternal::activateCallbacks(QInternal::AdoptCurrentThread, (void **) &adopted)) {
Q_ASSERT(adopted);
threadData = QThreadData::get2(adopted);
TlsSetValue(qt_current_thread_data_tls_index, threadData);
adopted->d_func()->running = true;
adopted->d_func()->finished = false;
static_cast<QAdoptedThread *>(adopted)->init();
} else {
threadData = new QThreadData;
// This needs to be called prior to new AdoptedThread() to
// avoid recursion.
TlsSetValue(qt_current_thread_data_tls_index, threadData);
threadData->thread = new QAdoptedThread(threadData);
threadData->deref();
}
const bool isMainThread = q_atomic_test_and_set_ptr(&QCoreApplicationPrivate::theMainThread, 0, threadData->thread);
if (!isMainThread) {
HANDLE realHandle;
DuplicateHandle(GetCurrentProcess(),
GetCurrentThread(),
GetCurrentProcess(),
&realHandle,
0,
FALSE,
DUPLICATE_SAME_ACCESS);
qt_watch_adopted_thread(realHandle, threadData->thread);
}
}
return threadData;
}