History

add basic threadpool functions https://rbcommons.com/s/OpenH264/r/1294/

Sijia Chen committed 11 years ago

Commit 757a5961 parent af6a9a814 files · +1043 −4Browse files

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

Unified · Split

codec/common/src/WelsThreadLib.cpp+16−2
@@ -274,8 +274,14 @@ WELS_THREAD_HANDLE WelsThreadSelf() { · 273 unmodified lines
274 274
275WELS_THREAD_ERROR_CODE WelsEventOpen (WELS_EVENT* p_event, const char* event_name) {275WELS_THREAD_ERROR_CODE WelsEventOpen (WELS_EVENT* p_event, const char* event_name) {
276#ifdef __APPLE__276#ifdef __APPLE__
277 if (p_event == NULL || event_name == NULL)277 if (p_event == NULL) {
278 return WELS_THREAD_ERROR_GENERAL;278 return WELS_THREAD_ERROR_GENERAL;
279 }
280 char strSuffix[16] = { 0 };
281 if (NULL == event_name) {
282 sprintf (strSuffix, "WelsSem%ld_p%ld", (intptr_t)p_event, (long) (getpid()));
283 event_name = &strSuffix[0];
284 }
279 *p_event = sem_open (event_name, O_CREAT, (S_IRUSR | S_IWUSR)/*0600*/, 0);285 *p_event = sem_open (event_name, O_CREAT, (S_IRUSR | S_IWUSR)/*0600*/, 0);
280 if (*p_event == (sem_t*)SEM_FAILED) {286 if (*p_event == (sem_t*)SEM_FAILED) {
281 sem_unlink (event_name);287 sem_unlink (event_name);
@@ -321,10 +327,18 @@ WELS_THREAD_ERROR_CODE WelsEventSignal (WELS_EVENT* event) { · 39 unmodified lines
321 return err;327 return err;
322}328}
323 329
324WELS_THREAD_ERROR_CODE WelsEventWait (WELS_EVENT* event) {330WELS_THREAD_ERROR_CODE WelsEventWait (WELS_EVENT* event) {
325 return sem_wait (*event); // blocking until signaled331 return sem_wait (*event); // blocking until signaled
326}332}
327 333
334void WelsSleep (uint32_t dwMilliSecond) {
335#ifdef WIN32
336 ::Sleep (dwMilliSecond);
337#else
338 usleep (dwMilliSecond * 1000);
339#endif
340}
341
328WELS_THREAD_ERROR_CODE WelsEventWaitWithTimeOut (WELS_EVENT* event, uint32_t dwMilliseconds) {342WELS_THREAD_ERROR_CODE WelsEventWaitWithTimeOut (WELS_EVENT* event, uint32_t dwMilliseconds) {
329 if (dwMilliseconds != (uint32_t) - 1) {343 if (dwMilliseconds != (uint32_t) - 1) {
330 return sem_wait (*event);344 return sem_wait (*event);

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