I have a process that uses different threads for making different type of jobs.
One such thread must send push notifications in a non-blocking way (so I will use libcurl because of the multi interface and SSL support). The master thread must pass the job to the worker and I thought about using apache apr message queue for message passing. Because in the same thread I must check for incoming messages and for the availability of the curl handles I think that I will use something like this:
while (1)
{
while (apr_queue_try_pop(queue, &msg) == APR_SUCCESS)
{
// do something with the message
}
// perform a select or poll in the curl multi handle
// treat the handles that are available for reads/writes
}
in the thread start function.
This is kind of busy waiting, is there a better solution?
Using C99 and Linux x86_64.