Reputation: 13733
I'm developing an application using POSIX threads.
The thread in question is receiving incoming data. Most of the time it is sleeping and waiting for something to happen.
But there are two issues here:
select()
and also waiting for events from virtual "ports", which might have no support for select()
(e.g. some specific Bluetooth / USB connections etc.). I will implement a notification mechanism for these ports - again, a simple POSIX condition signal should be enough.Now the question is - how to combine waiting on both select()
and pthread_cond_wait()
in a single runloop of a thread to wake it up on all of these events?
Number of ports (both TCP and "virtual") is expected to be low, under 5.
The solution should be reliable and work on Linux and BSD-like platforms (including Android and iOS).
Upvotes: 1
Views: 55