[omniORB] Condition varaibles - follow up...
Shinji Suzuki
suzuki@wni.co.jp
Thu, 21 Jan 1999 19:52:00 +0900
Ole,
You may not be using conidion vairable properly. Rather than doing
BufferItem
Buffer_i::GetItem()
{
while(!index){
// No items awailable. Wait on the condition varaible empty_buf:
empty_buf.wait();
}
mutex_region.lock();
BufferItem itm = TheBuffer[--index];
cout << "Returned item: " << itm << "\n" << flush;
// Signal one of the possible waiting threads on PutItem()
full_buf.signal();
mutex_region.unlock();
return itm;
}
you may have to do
BufferItem
Buffer_i::GetItem()
{
omni_mutex_lock l(omni_mutex_cond_mutex); // safer this way than m.lock()
while( !index ) {
// No items awailable. Wait on the condition varaible empty_buf:
empty_buf.wait();
}
BufferItem itm = TheBuffer[--index];
cout << "Returned item: " << item << "\n" << flush
// Signal one of the possible waiting threads on PutItem()
full_buf.signal();
return itm;
}
and apply similar changes elsewhere.
-shinji