1
gcc 4.7.2
c89

Hello,

I am using the APR safe thread queue in the utils library. My design is to use a thread to push a message to the queue and another thread to pop a message from the queue. This part is ok using apr thread pool and memory pools.

However, I want to block until there is something to pop from the queue. I want to use a semaphore to indicate there is something to pop from the queue. However, I could not see any semaphores in the APR-Utils.

I can use the posix semaphores but I would rather go with something more portable. As I am using APR would rather stick with that.

Does APR have semaphores, I could not see any?

Many thanks for any suggestions,

ant2009
  • 27,094
  • 154
  • 411
  • 609

1 Answers1

1

apr_queue_pop blocks if queue is empty, so there is no need for semaphores.

Anton Kovalenko
  • 20,999
  • 2
  • 37
  • 69
  • 1
    Thanks, I should have seen that. Just a quick question because I want to confirm something. As the queue is thread safe, and as I will using 2 different threads for pushing and popping. Does this mean I don't need to use a mutex to lock the queue for pushing/popping to the queue? – ant2009 Jan 05 '13 at 12:27
  • 1
    Yes, you don't need a mutex. – Anton Kovalenko Jan 05 '13 at 12:29