Boost logo

Boost Users :

Subject: [Boost-users] wait/notify problem
From: girish hilage (girish_hilage_at_[hidden])
Date: 2010-01-15 04:09:16


Hi,

   I am trying to implement MANAGER:WORKER model using boost thread_group.
   I am using wait() and notify() for that.

   In my application,
   when thread1 wants to listen for some event from thread2, it executes wait().
   when thread2 wants to inform about the event to thread1, it executes notify().

   The problem I am facing is :
   thread1 first executes wait().
   then thread2 executes notify().

   but notify() completes its execution even before thread1 actually starts waiting for the event and notify() is goes in vain and then thread1 keeps on waiting infinitely.

   To avoid this, right now I am using sleep(1) before thread2 calls notify() to make sure that thread1 really reaches the actual wait state.
   But this is not a permanent solution; as it is possible that even within 1sec thread1 might not actually start listening for the event. (Also 1sec makes my applcation very slow).
 
   So, I just want to know if there is any such mechanism which will enable thread2 to keep notify()ing until the event is accepted by thread1? i.e. blocked notify().

Regards,
Girish



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net