I have a number of data containers that can send a signal when there are updates in them. The structure looks similar like this:
typedef struct {
int data;
/*...*/
pthread_cond_t *onHaveUpdate;
} Container;
The onHaveUpdate is a pointer to a global condition that is shared by all the containers
In my application, I have a number of these structures and they can concurrently be updated by different threads.
Now, is it possible for me to have a thread that listens to the condition and can perform something on the container that sends the notification?
I know that this can be solved by using one thread per container but it feel like a waste of resources, but I was wondering if this can be done using only one thread for all container?