Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the equivalent linux API for WaitForMultipleObjects() and WSAEnumNetworkEvents()?

What is the equivalent linux API for WaitForMultipleObjects() and WSAEnumNetworkEvents()? Can we use pthread_cond_wait() for WaitForMultipleObjects?

like image 353
ABC Avatar asked Dec 17 '12 12:12

ABC


2 Answers

For developers coming from a Windows background, we faced the same issue when porting some code from Win32 to pthreads and created an open source (MIT-licensed) library called pevents which implements WaitForMultipleObjects() on Linux, with support for both auto and manual reset events. It should behave in the same way as WIN32 events on Windows do.

like image 200
Mahmoud Al-Qudsi Avatar answered Oct 19 '22 09:10

Mahmoud Al-Qudsi


Well there is no straightforward API in Linux, that does the WaitForMultipleObjects() equivalent.

WaitForSingleObject and WaitForMultipleObjects equivalent in Linux? contains answer to the first part and perhaps a better explanation too.

For WSAEnumNetworkEvents(), in Linux, use poll() or select() based on your requirements. Another application libevent might also be useful.

Reference:

  • poll(3) man page

  • select(3) man page

  • libevent

like image 26
askmish Avatar answered Oct 19 '22 08:10

askmish