Windows Phone lacks the old CreateThread/beginthreadex APIs for creating threads. (Technically, the functions still do exist, but they aren't officially supported and aren't visible in the headers when targeting Windows Phone.) Building code that uses the Windows Runtime language extensions requires building with the -ZW option.
Showing the changes to codec/common/src/WelsThreadLib.cpp (1 of 2 files). Show all
Unified · Split
| @@ -68,6 +68,11 @@ · 67 unmodified lines | ||
| 68 | 68 | |
| 69 | 69 | #ifdef WINAPI_FAMILY |
| 70 | 70 | #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) |
| 71 | +using namespace Platform; | |
| 72 | +using namespace Windows::Foundation; | |
| 73 | +using namespace Windows::System::Threading; | |
| 74 | +#define USE_THREADPOOL | |
| 75 | + | |
| 71 | 76 | #define InitializeCriticalSection(x) InitializeCriticalSectionEx(x, 0, 0) |
| 72 | 77 | #define GetSystemInfo(x) GetNativeSystemInfo(x) |
| 73 | 78 | #define CreateEvent(attr, reset, init, name) CreateEventEx(attr, name, ((reset) ? CREATE_EVENT_MANUAL_RESET : 0) | ((init) ? CREATE_EVENT_INITIAL_SET : 0), EVENT_ALL_ACCESS) |
| @@ -169,7 +174,18 @@ WELS_THREAD_ERROR_CODE WelsEventClose (WELS_EVENT* event, const char* event_n · 95 unmodified lines | ||
| 169 | 174 | |
| 170 | 175 | WELS_THREAD_ERROR_CODE WelsThreadCreate (WELS_THREAD_HANDLE* thread, LPWELS_THREAD_ROUTINE routine, |
| 171 | 176 | void* arg, WELS_THREAD_ATTR attr) { |
| 177 | +#ifdef USE_THREADPOOL | |
| 178 | + HANDLE h = CreateEvent(NULL, FALSE, FALSE, NULL); | |
| 179 | + HANDLE h2; | |
| 180 | + DuplicateHandle(GetCurrentProcess(), h, GetCurrentProcess(), &h2, 0, FALSE, DUPLICATE_SAME_ACCESS); | |
| 181 | + ThreadPool::RunAsync(ref new WorkItemHandler([=](IAsyncAction^) { | |
| 182 | + routine(arg); | |
| 183 | + SetEvent(h2); | |
| 184 | + CloseHandle(h2); | |
| 185 | + }, CallbackContext::Any), WorkItemPriority::Normal, WorkItemOptions::TimeSliced); | |
| 186 | +#else | |
| 172 | 187 | WELS_THREAD_HANDLE h = CreateThread (NULL, 0, routine, arg, 0, NULL); |
| 188 | +#endif | |
| 173 | 189 | |
| 174 | 190 | if (h == NULL) { |
| 175 | 191 | return WELS_THREAD_ERROR_GENERAL; |