History

Avoid using C++/CX code for threads for Windows Phone/Windows Store/UWP

The CreateThread function was only unavailable in Windows (Phone) 8.0, but became available again in Windows Phone 8.1 and for Store apps in Windows 8.1. This avoids building source files with the /ZW flag for C++/CX mode, simplifying integration with other projects and build systems.

Martin Storsjö committed 8 years ago

Commit 56a721d1 parent bb255193 files · +2 −26Browse files

Showing the changes to codec/common/src/WelsThreadLib.cpp (1 of 3 files). Show all

Unified · Split

codec/common/src/WelsThreadLib.cpp+0−15
@@ -74,10 +74,6 @@ · 73 unmodified lines
74#ifdef WINAPI_FAMILY74#ifdef WINAPI_FAMILY
75#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)75#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
76#define WP8076#define WP80
77using namespace Platform;
78using namespace Windows::Foundation;
79using namespace Windows::System::Threading;
80#define USE_THREADPOOL
81 77
82#define InitializeCriticalSection(x) InitializeCriticalSectionEx(x, 0, 0)78#define InitializeCriticalSection(x) InitializeCriticalSectionEx(x, 0, 0)
83#define GetSystemInfo(x) GetNativeSystemInfo(x)79#define GetSystemInfo(x) GetNativeSystemInfo(x)
@@ -200,18 +196,7 @@ void WelsSleep (uint32_t dwMilliSecond) { · 116 unmodified lines
200 196
201WELS_THREAD_ERROR_CODE WelsThreadCreate (WELS_THREAD_HANDLE* thread, LPWELS_THREAD_ROUTINE routine,197WELS_THREAD_ERROR_CODE WelsThreadCreate (WELS_THREAD_HANDLE* thread, LPWELS_THREAD_ROUTINE routine,
202 void* arg, WELS_THREAD_ATTR attr) {198 void* arg, WELS_THREAD_ATTR attr) {
203#ifdef USE_THREADPOOL
204 HANDLE h = CreateEvent (NULL, FALSE, FALSE, NULL);
205 HANDLE h2;
206 DuplicateHandle (GetCurrentProcess(), h, GetCurrentProcess(), &h2, 0, FALSE, DUPLICATE_SAME_ACCESS);
207 ThreadPool::RunAsync (ref new WorkItemHandler ([ = ] (IAsyncAction^) {
208 routine (arg);
209 SetEvent (h2);
210 CloseHandle (h2);
211 }, CallbackContext::Any), WorkItemPriority::Normal, WorkItemOptions::TimeSliced);
212#else
213 WELS_THREAD_HANDLE h = CreateThread (NULL, 0, routine, arg, 0, NULL);199 WELS_THREAD_HANDLE h = CreateThread (NULL, 0, routine, arg, 0, NULL);
214#endif
215 200
216 if (h == NULL) {201 if (h == NULL) {
217 return WELS_THREAD_ERROR_GENERAL;202 return WELS_THREAD_ERROR_GENERAL;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t