
On Wednesday 23 April 2003 14:10, Andreas Roth wrote:
i'm a Linux programming newbie. I developed several programs for Windows and i often use WaitForSingleObject and WaitForMultipleObjects in my programs. Is there a linux implementation of WaitForSingleObject and WaitForMultipleObjects?
There is no real equivalent. This is the one single issue where the Win32 API is better designed than the Linux/Unix POSIX API (which is a lot older than Win32). You cannot wait for all kinds of different objects at the same time; there are specific system calls to wait for different kinds of events. select() (it waits for sockets - see "man 2 select") comes close, but it can only wait for I/O events. Most windowing toolkits (Qt for one) provide an easy-to-use interface that integrates waiting for user sockets with waiting for windowing events (most windowing toolkits use nothing else than select() internally).
Or, how can i wait for multiple objects (event, semaphores, etc) ?
This usually only works if you stick with one toolkit. Qt for example provides QMutex, QSemaphore, QSocket etc. that emulate that behaviour. In general, however, this doesn't work. POSIX provides the semop() system call that waits for semaphores, select() that waits for sockets(), wait() that waits for child processes etc. - different wait system calls that wait for different things. Hope this helps. CU -- Stefan Hundhammer <sh@suse.de> Penguin by conviction. YaST2 Development SuSE Linux AG Nuernberg, Germany