diff options
Diffstat (limited to 'src/corelib/thread')
-rw-r--r-- | src/corelib/thread/qmutex_win.cpp | 4 | ||||
-rw-r--r-- | src/corelib/thread/qthread.cpp | 2 | ||||
-rw-r--r-- | src/corelib/thread/qthread_p.h | 13 | ||||
-rw-r--r-- | src/corelib/thread/qthread_win.cpp | 121 | ||||
-rw-r--r-- | src/corelib/thread/qwaitcondition_win.cpp | 6 |
5 files changed, 9 insertions, 137 deletions
diff --git a/src/corelib/thread/qmutex_win.cpp b/src/corelib/thread/qmutex_win.cpp index e221bc89cb..73673cd5fb 100644 --- a/src/corelib/thread/qmutex_win.cpp +++ b/src/corelib/thread/qmutex_win.cpp @@ -46,11 +46,7 @@ QT_BEGIN_NAMESPACE QMutexPrivate::QMutexPrivate() { -#ifndef Q_OS_WINRT event = CreateEvent(0, FALSE, FALSE, 0); -#else - event = CreateEventEx(0, NULL, 0, EVENT_ALL_ACCESS); -#endif if (!event) qWarning("QMutexData::QMutexData: Cannot create event"); diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp index d575253408..36e9b2a7a2 100644 --- a/src/corelib/thread/qthread.cpp +++ b/src/corelib/thread/qthread.cpp @@ -184,9 +184,7 @@ QThreadPrivate::QThreadPrivate(QThreadData *d) #if defined (Q_OS_WIN) handle = 0; -# ifndef Q_OS_WINRT id = 0; -# endif waiters = 0; terminationEnabled = true; terminatePending = false; diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h index b2d1628e6e..9255b05104 100644 --- a/src/corelib/thread/qthread_p.h +++ b/src/corelib/thread/qthread_p.h @@ -67,16 +67,6 @@ #include <algorithm> #include <atomic> -#ifdef Q_OS_WINRT -namespace ABI { - namespace Windows { - namespace Foundation { - struct IAsyncAction; - } - } -} -#endif // Q_OS_WINRT - QT_BEGIN_NAMESPACE class QAbstractEventDispatcher; @@ -246,9 +236,6 @@ public: ~QThreadData(); static Q_AUTOTEST_EXPORT QThreadData *current(bool createIfNecessary = true); -#ifdef Q_OS_WINRT - static void setMainThread(); -#endif static void clearCurrentThreadData(); static QThreadData *get2(QThread *thread) { Q_ASSERT_X(thread != nullptr, "QThread", "internal error"); return thread->d_func()->data; } diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp index 00d67b3a00..78c4d8d672 100644 --- a/src/corelib/thread/qthread_win.cpp +++ b/src/corelib/thread/qthread_win.cpp @@ -46,49 +46,19 @@ #include <qpointer.h> #include <private/qcoreapplication_p.h> -#ifndef Q_OS_WINRT #include <private/qeventdispatcher_win_p.h> -#else -#include <private/qeventdispatcher_winrt_p.h> -#endif #include <qt_windows.h> -#ifndef Q_OS_WINRT -# ifndef _MT -# define _MT -# endif // _MT -# include <process.h> -#endif // Q_OS_WINRT +#ifndef _MT +# define _MT +#endif // _MT +#include <process.h> QT_BEGIN_NAMESPACE #if QT_CONFIG(thread) -#ifdef Q_OS_WINRT -inline DWORD qWinRTTlsAlloc() { - return FlsAlloc(0); -} - -inline bool qWinRTTlsFree(DWORD dwTlsIndex) { - return FlsFree(dwTlsIndex); -} - -inline LPVOID qWinRTTlsGetValue(DWORD dwTlsIndex) { - return FlsGetValue(dwTlsIndex); -} - -inline bool qWinRTTlsSetValue(DWORD dwTlsIndex, LPVOID lpTlsValue) { - return FlsSetValue(dwTlsIndex, lpTlsValue); -} - -#define TlsAlloc qWinRTTlsAlloc -#define TlsFree qWinRTTlsFree -#define TlsSetValue qWinRTTlsSetValue -#define TlsGetValue qWinRTTlsGetValue - -#endif // Q_OS_WINRT - void qt_watch_adopted_thread(const HANDLE adoptedThreadHandle, QThread *qthread); DWORD WINAPI qt_adopted_thread_watcher_function(LPVOID); @@ -142,15 +112,9 @@ QThreadData *QThreadData::current(bool createIfNecessary) threadData->isAdopted = true; threadData->threadId.storeRelaxed(reinterpret_cast<Qt::HANDLE>(quintptr(GetCurrentThreadId()))); -#ifndef Q_OS_WINRT if (!QCoreApplicationPrivate::theMainThread) { QCoreApplicationPrivate::theMainThread = threadData->thread.loadRelaxed(); } else { -#else - // for winrt the main thread is set explicitly in QCoreApplication's constructor as the - // native main thread (Xaml thread) is not Qt's main thread. - { -#endif HANDLE realHandle = INVALID_HANDLE_VALUE; DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), @@ -165,33 +129,6 @@ QThreadData *QThreadData::current(bool createIfNecessary) return threadData; } -#ifdef Q_OS_WINRT -void QThreadData::setMainThread() -{ - Q_ASSERT(!QCoreApplicationPrivate::theMainThread); - qt_create_tls(); - QThreadData *threadData = reinterpret_cast<QThreadData *>(TlsGetValue(qt_current_thread_data_tls_index)); - if (!threadData) { - 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(); - threadData->isAdopted = true; - threadData->threadId.storeRelaxed(reinterpret_cast<Qt::HANDLE>(quintptr(GetCurrentThreadId()))); - } - QCoreApplicationPrivate::theMainThread = threadData->thread.loadRelaxed(); -} -#endif - void QAdoptedThread::init() { d_func()->handle = GetCurrentThread(); @@ -225,11 +162,7 @@ void qt_watch_adopted_thread(const HANDLE adoptedThreadHandle, QThread *qthread) // Start watcher thread if it is not already running. if (qt_adopted_thread_watcher_id == 0) { if (qt_adopted_thread_wakeup == 0) { -#ifndef Q_OS_WINRT qt_adopted_thread_wakeup = CreateEvent(0, false, false, 0); -#else - qt_adopted_thread_wakeup = CreateEventEx(0, NULL, 0, EVENT_ALL_ACCESS); -#endif qt_adopted_thread_handles.prepend(qt_adopted_thread_wakeup); } @@ -268,21 +201,13 @@ DWORD WINAPI qt_adopted_thread_watcher_function(LPVOID) // no need to loop, no timeout offset = 0; count = handlesCopy.count(); -#ifndef Q_OS_WINRT ret = WaitForMultipleObjects(handlesCopy.count(), handlesCopy.constData(), false, INFINITE); -#else - ret = WaitForMultipleObjectsEx(handlesCopy.count(), handlesCopy.constData(), false, INFINITE, false); -#endif } else { int loop = 0; do { offset = loop * MAXIMUM_WAIT_OBJECTS; count = qMin(handlesCopy.count() - offset, MAXIMUM_WAIT_OBJECTS); -#ifndef Q_OS_WINRT ret = WaitForMultipleObjects(count, handlesCopy.constData() + offset, false, 100); -#else - ret = WaitForMultipleObjectsEx(count, handlesCopy.constData() + offset, false, 100, false); -#endif loop = (loop + 1) % loops; } while (ret == WAIT_TIMEOUT); } @@ -323,7 +248,7 @@ DWORD WINAPI qt_adopted_thread_watcher_function(LPVOID) return 0; } -#if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINRT) +#if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) #ifndef Q_OS_WIN64 # define ULONG_PTR DWORD @@ -354,7 +279,7 @@ void qt_set_thread_name(HANDLE threadId, LPCSTR threadName) { } } -#endif // !QT_NO_DEBUG && Q_CC_MSVC && !Q_OS_WINRT +#endif // !QT_NO_DEBUG && Q_CC_MSVC /************************************************************************** ** QThreadPrivate @@ -365,11 +290,7 @@ void qt_set_thread_name(HANDLE threadId, LPCSTR threadName) QAbstractEventDispatcher *QThreadPrivate::createEventDispatcher(QThreadData *data) { Q_UNUSED(data); -#ifndef Q_OS_WINRT return new QEventDispatcherWin32; -#else - return new QEventDispatcherWinRT; -#endif } #if QT_CONFIG(thread) @@ -392,7 +313,7 @@ unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(voi data->ensureEventDispatcher(); -#if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINRT) +#if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) // sets the name of the current thread. QByteArray objectName = thr->objectName().toLocal8Bit(); qt_set_thread_name(HANDLE(-1), @@ -457,11 +378,7 @@ Qt::HANDLE QThread::currentThreadIdImpl() noexcept int QThread::idealThreadCount() noexcept { SYSTEM_INFO sysinfo; -#ifndef Q_OS_WINRT GetSystemInfo(&sysinfo); -#else - GetNativeSystemInfo(&sysinfo); -#endif return sysinfo.dwNumberOfProcessors; } @@ -519,16 +436,7 @@ void QThread::start(Priority priority) less than NormalPriority), but the newly created thread preempts its 'parent' and runs at normal priority. */ -#if defined(Q_CC_MSVC) && !defined(_DLL) // && !defined(Q_OS_WINRT) -# ifdef Q_OS_WINRT - // If you wish to accept the memory leaks, uncomment the part above. - // See: - // https://support.microsoft.com/en-us/kb/104641 - // https://msdn.microsoft.com/en-us/library/kdzttdcb.aspx -# error "Microsoft documentation says this combination leaks memory every time a thread is started. " \ - "Please change your build back to -MD/-MDd or, if you understand this issue and want to continue, " \ - "edit this source file." -# endif +#if defined(Q_CC_MSVC) && !defined(_DLL) // MSVC -MT or -MTd build d->handle = (Qt::HANDLE) _beginthreadex(NULL, d->stackSize, QThreadPrivate::start, this, CREATE_SUSPENDED, &(d->id)); @@ -537,7 +445,7 @@ void QThread::start(Priority priority) d->handle = CreateThread(nullptr, d->stackSize, reinterpret_cast<LPTHREAD_START_ROUTINE>(QThreadPrivate::start), this, CREATE_SUSPENDED, reinterpret_cast<LPDWORD>(&d->id)); -#endif // Q_OS_WINRT +#endif if (!d->handle) { qErrnoWarning("QThread::start: Failed to create thread"); @@ -603,10 +511,7 @@ void QThread::terminate() return; } - // Calling ExitThread() in setTerminationEnabled is all we can do on WinRT -#ifndef Q_OS_WINRT TerminateThread(d->handle, 0); -#endif QThreadPrivate::finish(this, false); } @@ -626,11 +531,7 @@ bool QThread::wait(QDeadlineTimer deadline) locker.mutex()->unlock(); bool ret = false; -#ifndef Q_OS_WINRT switch (WaitForSingleObject(d->handle, deadline.remainingTime())) { -#else - switch (WaitForSingleObjectEx(d->handle, deadline.remainingTime(), false)) { -#endif case WAIT_OBJECT_0: ret = true; break; @@ -671,11 +572,7 @@ void QThread::setTerminationEnabled(bool enabled) if (enabled && d->terminatePending) { QThreadPrivate::finish(thr, false); locker.unlock(); // don't leave the mutex locked! -#ifndef Q_OS_WINRT _endthreadex(0); -#else - ExitThread(0); -#endif } } diff --git a/src/corelib/thread/qwaitcondition_win.cpp b/src/corelib/thread/qwaitcondition_win.cpp index a6ad95b397..ba34129b7f 100644 --- a/src/corelib/thread/qwaitcondition_win.cpp +++ b/src/corelib/thread/qwaitcondition_win.cpp @@ -61,11 +61,7 @@ class QWaitConditionEvent public: inline QWaitConditionEvent() : priority(0), wokenUp(false) { -#ifndef Q_OS_WINRT event = CreateEvent(NULL, TRUE, FALSE, NULL); -#else - event = CreateEventEx(NULL, NULL, CREATE_EVENT_MANUAL_RESET, EVENT_ALL_ACCESS); -#endif } inline ~QWaitConditionEvent() { CloseHandle(event); } int priority; @@ -92,9 +88,7 @@ QWaitConditionEvent *QWaitConditionPrivate::pre() mtx.lock(); QWaitConditionEvent *wce = freeQueue.isEmpty() ? new QWaitConditionEvent : freeQueue.takeFirst(); -#ifndef Q_OS_WINRT wce->priority = GetThreadPriority(GetCurrentThread()); -#endif wce->wokenUp = false; // insert 'wce' into the queue (sorted by priority) |