thread: use CreateThread for windows phone

_beginthreadex is unavailable for winrt/uwp

Change-Id: Ie7412a568278ac67f0047f1764e2521193d74d4d
This commit is contained in:
James Zern 2015-11-23 20:41:26 -08:00
parent 0fd0e12bfe
commit d2afe974f9

View File

@ -35,6 +35,15 @@ typedef struct {
} pthread_cond_t;
#endif // _WIN32_WINNT >= 0x600
#ifndef WINAPI_FAMILY_PARTITION
#define WINAPI_PARTITION_DESKTOP 1
#define WINAPI_FAMILY_PARTITION(x) x
#endif
#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
#define USE_CREATE_THREAD
#endif
#else // !_WIN32
#include <pthread.h>
@ -66,12 +75,21 @@ struct WebPWorkerImpl {
static int pthread_create(pthread_t* const thread, const void* attr,
unsigned int (__stdcall *start)(void*), void* arg) {
(void)attr;
#ifdef USE_CREATE_THREAD
*thread = CreateThread(NULL, /* lpThreadAttributes */
0, /* dwStackSize */
start,
arg,
0, /* dwStackSize */
NULL); /* lpThreadId */
#else
*thread = (pthread_t)_beginthreadex(NULL, /* void *security */
0, /* unsigned stack_size */
start,
arg,
0, /* unsigned initflag */
NULL); /* unsigned *thrdaddr */
#endif
if (*thread == NULL) return 1;
SetThreadPriority(*thread, THREAD_PRIORITY_ABOVE_NORMAL);
return 0;