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
274274
275275 WELS_THREAD_ERROR_CODE WelsEventOpen (WELS_EVENT* p_event, const char* event_name) {
276276 #ifdef __APPLE__
277− if (p_event == NULL || event_name == NULL)
277+ if (p_event == NULL) {
278278 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+ }
279285 *p_event = sem_open (event_name, O_CREAT, (S_IRUSR | S_IWUSR)/*0600*/, 0);
280286 if (*p_event == (sem_t*)SEM_FAILED) {
281287 sem_unlink (event_name);
@@ -321,10 +327,18 @@ WELS_THREAD_ERROR_CODE WelsEventSignal (WELS_EVENT* event) { · 39 unmodified lines
321327 return err;
322328 }
323329
324−WELS_THREAD_ERROR_CODE WelsEventWait (WELS_EVENT* event) {
330+WELS_THREAD_ERROR_CODE WelsEventWait (WELS_EVENT* event) {
325331 return sem_wait (*event); // blocking until signaled
326332 }
327333
334+void WelsSleep (uint32_t dwMilliSecond) {
335+#ifdef WIN32
336+ ::Sleep (dwMilliSecond);
337+#else
338+ usleep (dwMilliSecond * 1000);
339+#endif
340+}
341+
328342 WELS_THREAD_ERROR_CODE WelsEventWaitWithTimeOut (WELS_EVENT* event, uint32_t dwMilliseconds) {
329343 if (dwMilliseconds != (uint32_t) - 1) {
330344 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