Hi boost users,<div><br></div><div>I've discovered that the following doesn't compile.</div><div><br></div><div><div><font class="Apple-style-span" face="'courier new', monospace">�� using namespace boost::interprocess;</font></div> <div><font class="Apple-style-span" face="'courier new', monospace">�� interprocess_upgradable_mutex mutex;</font></div><div><font class="Apple-style-span" face="'courier new', monospace">�� interprocess_condition cv;</font></div> <div><font class="Apple-style-span" face="'courier new', monospace">�� boost::posix_time::ptime deadline;</font></div><div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div> <font class="Apple-style-span" face="'courier new', monospace">�� {</font></div><div><font class="Apple-style-span" face="'courier new', monospace">�� � �scoped_lock<interprocess_upgradable_mutex> lock(mutex);</font></div> <div><font class="Apple-style-span" face="'courier new', monospace">�� � �sharable_lock<interprocess_upgradable_mutex> lock2(mutex);</font></div><div><font class="Apple-style-span" face="'courier new', monospace">�� � �cv.wait(lock); // doesn't compile</font></div> <div><font class="Apple-style-span" face="'courier new', monospace">�� � �cv.timed_wait(lock, deadline); // doesn't compile.</font></div><div><font class="Apple-style-span" face="'courier new', monospace">�� }</font></div> </div><div><br></div><div>It is failing because boost doesn't define the following methods:</div><div><br></div><div><div>�� <font class="Apple-style-span" face="'courier new', monospace">void interprocess_condition::do_wait(interprocess_upgradable_mutex �&mut);</font></div> <div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><font class="Apple-style-span" face="'courier new', monospace">�� bool�interprocess_condition::do_timed_wait(const syssrv_boost::posix_time::ptime &abs_time, interprocess_upgradable_mutex &mut);</font></div> </div><div><br></div><div>I was thinking of making a basic implementation like so:</div><div><br></div><div>Define a <font class="Apple-style-span" face="'courier new', monospace">scoped_unlock </font>class, which behaves just like <font class="Apple-style-span" face="'courier new', monospace">scoped_lock</font> except the constructor unlocks and the destructor locks.</div> <div><br></div><div>Then define the following:</div><div><br></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div><font class="Apple-style-span" face="'courier new', monospace">inline void interprocess_condition::do_wait(interprocess_upgradable_mutex &mut)</font></div> </div><div><div><font class="Apple-style-span" face="'courier new', monospace">{</font></div></div><div><div><font class="Apple-style-span" face="'courier new', monospace">�� scoped_unlock<interprocess_upgradable_mutex> unlock(mut);</font></div> </div><div><div><font class="Apple-style-span" face="'courier new', monospace">�� interprocess_mutex &internal_mutex = mut.m_mut;</font></div></div><div><div><font class="Apple-style-span" face="'courier new', monospace">�� scoped_lock<interprocess_mutex> internal_lock(internal_mutex);</font></div> </div><div><div><font class="Apple-style-span" face="'courier new', monospace">�� this->wait(internal_lock);</font></div></div><div><div><font class="Apple-style-span" face="'courier new', monospace">}</font></div> </div><div><div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div></div><div><div><font class="Apple-style-span" face="'courier new', monospace">inline bool interprocess_condition::do_timed_wait</font></div> </div><div><div><font class="Apple-style-span" face="'courier new', monospace">�� (const syssrv_boost::posix_time::ptime &abs_time, interprocess_upgradable_mutex &mut)</font></div></div><div><div><font class="Apple-style-span" face="'courier new', monospace">{</font></div> </div><div><div><font class="Apple-style-span" face="'courier new', monospace">�� scoped_unlock<interprocess_upgradable_mutex> unlock(mut);</font></div></div><div><div><font class="Apple-style-span" face="'courier new', monospace">�� interprocess_mutex &internal_mutex = mut.m_mut;</font></div> </div><div><div><font class="Apple-style-span" face="'courier new', monospace">�� scoped_lock<interprocess_mutex> internal_lock(internal_mutex);</font></div></div><div><div><font class="Apple-style-span" face="'courier new', monospace">�� return this->timed_wait(internal_lock, abs_time);</font></div> </div><div><div><font class="Apple-style-span" face="'courier new', monospace">}</font></div></div></blockquote><div><br></div><div>These functions simply do the following:</div><div><ul><li>unlock the exclusive lock on the�<span class="Apple-style-span" style="font-family: 'courier new', monospace; ">interprocess_upgradable_mutex</span>�(which is emulated with an internal�<span class="Apple-style-span" style="font-family: 'courier new', monospace; ">interprocess_mutex</span>)</li> <li>then lock the internal�<span class="Apple-style-span" style="font-family: 'courier new', monospace; ">interprocess_mutex</span></li><li>Call <font class="Apple-style-span" face="'courier new', monospace">interprocess_condition::wait</font> or�<font class="Apple-style-span" face="'courier new', monospace">interprocess_condition::time_ wait</font>�on the implementation lock which does all the work</li> <li>unlock the internal�<span class="Apple-style-span" style="font-family: 'courier new', monospace; ">interprocess_mutex</span></li><li>relock the exclusive lock on��the�<span class="Apple-style-span" style="font-family: 'courier new', monospace; ">interprocess_upgradable_mutex</span>�</li> </ul></div><div>Intuitively, this should work.</div><div><br></div><div>Is there anything I missed that would make this an incorrect implementation?</div><div><br></div><div>Cheers,</div><div><br></div><div>-John</div><div> <br></div>