Showing the changes to codec/common/src/WelsThreadLib.cpp (1 of 57 files). Show all
Unified · Split
| @@ -299,12 +299,12 @@ WELS_THREAD_ERROR_CODE WelsEventOpen (WELS_EVENT* p_event, const char* event_ · 298 unmodified lines | |||
| 299 | } | 299 | } |
| 300 | WELS_THREAD_ERROR_CODE WelsEventClose (WELS_EVENT* event, const char* event_name) { | 300 | WELS_THREAD_ERROR_CODE WelsEventClose (WELS_EVENT* event, const char* event_name) { |
| 301 | #ifdef __APPLE__ | 301 | #ifdef __APPLE__ |
| 302 | WELS_THREAD_ERROR_CODE err = sem_close (*event); // match with sem_open | 302 | WELS_THREAD_ERROR_CODE err = sem_close (*event); // match with sem_open |
| 303 | if (event_name) | 303 | if (event_name) |
| 304 | sem_unlink (event_name); | 304 | sem_unlink (event_name); |
| 305 | return err; | 305 | return err; |
| 306 | #else | 306 | #else |
| 307 | WELS_THREAD_ERROR_CODE err = sem_destroy (*event); // match with sem_init | 307 | WELS_THREAD_ERROR_CODE err = sem_destroy (*event); // match with sem_init |
| 308 | free (*event); | 308 | free (*event); |
| 309 | return err; | 309 | return err; |
| 310 | #endif | 310 | #endif |
| @@ -322,7 +322,7 @@ WELS_THREAD_ERROR_CODE WelsEventSignal (WELS_EVENT* event) { · 11 unmodified lines | |||
| 322 | } | 322 | } |
| 323 | 323 | ||
| 324 | WELS_THREAD_ERROR_CODE WelsEventWait (WELS_EVENT* event) { | 324 | WELS_THREAD_ERROR_CODE WelsEventWait (WELS_EVENT* event) { |
| 325 | return sem_wait (*event); // blocking until signaled | 325 | return sem_wait (*event); // blocking until signaled |
| 326 | } | 326 | } |
| 327 | 327 | ||
| 328 | WELS_THREAD_ERROR_CODE WelsEventWaitWithTimeOut (WELS_EVENT* event, uint32_t dwMilliseconds) { | 328 | WELS_THREAD_ERROR_CODE WelsEventWaitWithTimeOut (WELS_EVENT* event, uint32_t dwMilliseconds) { |
| @@ -360,7 +360,7 @@ WELS_THREAD_ERROR_CODE WelsEventWaitWithTimeOut (WELS_EVENT* event, uint32_t · 31 unmodified lines | |||
| 360 | WELS_THREAD_ERROR_CODE WelsMultipleEventsWaitSingleBlocking (uint32_t nCount, | 360 | WELS_THREAD_ERROR_CODE WelsMultipleEventsWaitSingleBlocking (uint32_t nCount, |
| 361 | WELS_EVENT* event_list, WELS_EVENT* master_event) { | 361 | WELS_EVENT* event_list, WELS_EVENT* master_event) { |
| 362 | uint32_t nIdx = 0; | 362 | uint32_t nIdx = 0; |
| 363 | uint32_t uiAccessTime = 2; // 2 us once | 363 | uint32_t uiAccessTime = 2; // 2 us once |
| 364 | 364 | ||
| 365 | if (nCount == 0) | 365 | if (nCount == 0) |
| 366 | return WELS_THREAD_ERROR_WAIT_FAILED; | 366 | return WELS_THREAD_ERROR_WAIT_FAILED; |
| @@ -378,7 +378,7 @@ WELS_THREAD_ERROR_CODE WelsMultipleEventsWaitSingleBlocking (uint32_t nCount, · 11 unmodified lines | |||
| 378 | } | 378 | } |
| 379 | 379 | ||
| 380 | while (1) { | 380 | while (1) { |
| 381 | nIdx = 0; // access each event by order | 381 | nIdx = 0; // access each event by order |
| 382 | while (nIdx < nCount) { | 382 | while (nIdx < nCount) { |
| 383 | int32_t err = 0; | 383 | int32_t err = 0; |
| 384 | int32_t wait_count = 0; | 384 | int32_t wait_count = 0; |
| @@ -399,7 +399,7 @@ WELS_THREAD_ERROR_CODE WelsMultipleEventsWaitSingleBlocking (uint32_t nCount, · 14 unmodified lines | |||
| 399 | // we do need access next event next time | 399 | // we do need access next event next time |
| 400 | ++ nIdx; | 400 | ++ nIdx; |
| 401 | } | 401 | } |
| 402 | usleep (1); // switch to working threads | 402 | usleep (1); // switch to working threads |
| 403 | if (master_event != NULL) { | 403 | if (master_event != NULL) { |
| 404 | // A master event was used and was signalled, but none of the events in the | 404 | // A master event was used and was signalled, but none of the events in the |
| 405 | // list was found to be signalled, thus wait a little more when rechecking | 405 | // list was found to be signalled, thus wait a little more when rechecking |
| @@ -423,7 +423,7 @@ WELS_THREAD_ERROR_CODE WelsMultipleEventsWaitAllBlocking (uint32_t nCount, · 17 unmodified lines | |||
| 423 | return WELS_THREAD_ERROR_WAIT_FAILED; | 423 | return WELS_THREAD_ERROR_WAIT_FAILED; |
| 424 | 424 | ||
| 425 | while (1) { | 425 | while (1) { |
| 426 | nIdx = 0; // access each event by order | 426 | nIdx = 0; // access each event by order |
| 427 | while (nIdx < nCount) { | 427 | while (nIdx < nCount) { |
| 428 | const uint32_t kuiBitwiseFlag = (1 << nIdx); | 428 | const uint32_t kuiBitwiseFlag = (1 << nIdx); |
| 429 | 429 | ||