Showing the changes to codec/common/src/WelsThreadLib.cpp (1 of 2 files). Show all
Unified · Split
| @@ -71,6 +71,7 @@ · 70 unmodified lines | ||
| 71 | 71 | |
| 72 | 72 | #ifdef WINAPI_FAMILY |
| 73 | 73 | #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) |
| 74 | +#define WP80 | |
| 74 | 75 | using namespace Platform; |
| 75 | 76 | using namespace Windows::Foundation; |
| 76 | 77 | using namespace Windows::System::Threading; |
| @@ -174,9 +175,30 @@ WELS_THREAD_ERROR_CODE WelsEventClose (WELS_EVENT* event, const char* event_n · 97 unmodified lines | ||
| 174 | 175 | return WELS_THREAD_ERROR_OK; |
| 175 | 176 | } |
| 176 | 177 | |
| 178 | +#ifndef WP80 | |
| 177 | 179 | void WelsSleep (uint32_t dwMilliSecond) { |
| 178 | 180 | ::Sleep (dwMilliSecond); |
| 179 | 181 | } |
| 182 | +#else | |
| 183 | +void WelsSleep (uint32_t dwMilliSecond) { | |
| 184 | + static WELS_EVENT hSleepEvent = NULL; | |
| 185 | + if (!hSleepEvent) { | |
| 186 | + WELS_EVENT hLocalSleepEvent = NULL; | |
| 187 | + WELS_THREAD_ERROR_CODE ret = WelsEventOpen (&hLocalSleepEvent); | |
| 188 | + if (WELS_THREAD_ERROR_OK != ret) { | |
| 189 | + return; | |
| 190 | + } | |
| 191 | + WELS_EVENT hPreviousEvent = InterlockedCompareExchangePointerRelease (&hSleepEvent, hLocalSleepEvent, NULL); | |
| 192 | + if (hPreviousEvent) { | |
| 193 | + WelsEventClose (&hLocalSleepEvent); | |
| 194 | + } | |
| 195 | + //On this singleton usage idea of using InterlockedCompareExchangePointerRelease: | |
| 196 | + // similar idea of can be found at msdn blog when introducing InterlockedCompareExchangePointerRelease | |
| 197 | + } | |
| 198 | + | |
| 199 | + WaitForSingleObject (hSleepEvent, dwMilliSecond); | |
| 200 | +} | |
| 201 | +#endif | |
| 180 | 202 | |
| 181 | 203 | WELS_THREAD_ERROR_CODE WelsThreadCreate (WELS_THREAD_HANDLE* thread, LPWELS_THREAD_ROUTINE routine, |
| 182 | 204 | void* arg, WELS_THREAD_ATTR attr) { |
| @@ -229,7 +251,7 @@ WELS_THREAD_ERROR_CODE WelsQueryLogicalProcessInfo (WelsLogicalProcessInfo* p · 46 unmodified lines | ||
| 229 | 251 | return WELS_THREAD_ERROR_OK; |
| 230 | 252 | } |
| 231 | 253 | |
| 232 | −#else | |
| 254 | +#else //platform: #ifdef _WIN32 | |
| 233 | 255 | |
| 234 | 256 | WELS_THREAD_ERROR_CODE WelsThreadCreate (WELS_THREAD_HANDLE* thread, LPWELS_THREAD_ROUTINE routine, |
| 235 | 257 | void* arg, WELS_THREAD_ATTR attr) { |