[prev in list] [next in list] [prev in thread] [next in thread] 

List:       boost-commit
Subject:    [Boost-commit] svn:boost r41518 - sandbox/committee/LWG
From:       hinnant () twcny ! rr ! com
Date:       2007-11-30 23:05:10
Message-ID: 20071130230510.68FF82F824F () wowbagger ! osl ! iu ! edu
[Download RAW message or body]

Author: hinnant
Date: 2007-11-30 18:05:09 EST (Fri, 30 Nov 2007)
New Revision: 41518
URL: http://svn.boost.org/trac/boost/changeset/41518

Log:
Added cv::timed_wait overloads
Text files modified: 
   sandbox/committee/LWG/thread_library.html |    72 \
+++++++++++++++++++++++----------------   1 files changed, 43 insertions(+), 29 \
deletions(-)

Modified: sandbox/committee/LWG/thread_library.html
==============================================================================
--- sandbox/committee/LWG/thread_library.html	(original)
+++ sandbox/committee/LWG/thread_library.html	2007-11-30 18:05:09 EST (Fri, 30 Nov \
2007) @@ -2685,6 +2685,8 @@
     void wait(unique_lock&lt;mutex&gt;&amp; <var>lock</var>);
     template &lt;class Predicate&gt;
         void wait(unique_lock&lt;mutex&gt;&amp; <var>lock</var>, Predicate \
<var>pred</var>); +    template &lt;class Duration&gt;
+        bool timed_wait(unique_lock&lt;mutex&gt;&amp; <var>lock</var>, const \
                Duration&amp; <var>rel_time</var>);
     bool timed_wait(unique_lock&lt;mutex&gt;&amp; <var>lock</var>, const \
system_time&amp; <var>abs_time</var>);  template &lt;class Predicate&gt;
         bool timed_wait(unique_lock&lt;mutex&gt;&amp; <var>lock</var>, const \
system_time&amp; <var>abs_time</var>, Predicate <var>pred</var>); @@ -2928,40 \
+2930,28 @@  </dd>
 </dl>
 
-<p>
-[<i>Note:</i>
-For condition variables,
-time duration overloads are not provided
-for the <code>timed_wait</code> members
-that do not take a <code>Predicate</code>.
-Spurious wakeups would cause endless loops
-unless extraordinary care were taken.
-The composability of absolute time provides an equivalent,
-but terminating, idiom:
-</p>
+</blockquote>
 
-<blockquote>
 <pre><code>
-mutex mut;
-condition_variable cv;
-...
-system_time abs_time = get_system_time() + seconds(1);
-bool within_time = true;
-while (within_time &amp;&amp; !pred())
-    within_time = cv.timed_wait(mut, abs_time);
-if (pred()) ...
+template &lt;class Duration&gt;
+    bool timed_wait(unique_lock&lt;mutex&gt;&amp; <var>lock</var>, const \
Duration&amp; <var>rel_time</var>);  </code></pre>
-</blockquote>
 
-<p>
-Notice that changing the <code>time_wait</code> call
-to <code>cv.timed_wait(mut, get_system_time() + seconds(1))</code>
-to eliminate the <code>abs_time</code> variable could result in an endless loop.
-</p>
+<blockquote>
+<dl>
+<dt>Effects:</dt>
+<dd>
+As if returns <code>timed_wait(<var>lock</var>, get_current_time() + \
<var>rel_time</var>)</code>. +</dd>
 
-<p>
-<i>--end note</i>]
-</p>
+<dt>Returns:</dt>
+<dd>
+<code>true</code> if the call to <code>timed_wait</code> is notified
+prior to the indicated timeout,
+otherwise returns <code>false</code>.
+</dd>
+
+</dl>
 </blockquote>
 
 <pre><code>
@@ -3090,6 +3080,8 @@
         void wait(Lock&amp; <var>lock</var>, Predicate <var>pred</var>);
     template &lt;class Lock&gt;
         bool timed_wait(Lock&amp; <var>lock</var>, const system_time&amp; \
<var>abs_time</var>); +    template &lt;class Lock, class Duration&gt;
+        bool timed_wait(Lock&amp; <var>lock</var>, const Duration&amp; \
<var>rel_time</var>);  template &lt;class Lock, class Predicate&gt;
         bool timed_wait(Lock&amp; <var>lock</var>, const system_time&amp; \
<var>abs_time</var>, Predicate <var>pred</var>);  template &lt;class Lock, class \
Duration, class Predicate&gt; @@ -3297,6 +3289,28 @@
 </blockquote>
 
 <pre><code>
+template &lt;class Lock, class Duration&gt;
+    bool timed_wait(Lock&amp; <var>lock</var>, const Duration&amp; \
<var>rel_time</var>); +</code></pre>
+
+<blockquote>
+<dl>
+<dt>Effects:</dt>
+<dd>
+As if returns <code>timed_wait(<var>lock</var>, get_current_time() + \
<var>rel_time</var>)</code>. +</dd>
+
+<dt>Returns:</dt>
+<dd>
+<code>true</code> if the call to <code>timed_wait</code> is notified
+prior to the indicated timeout,
+otherwise returns <code>false</code>.
+</dd>
+
+</dl>
+</blockquote>
+
+<pre><code>
 template &lt;class Lock, class Predicate&gt;
     bool timed_wait(Lock&amp; <var>lock</var>, const system_time&amp; \
<var>abs_time</var>, Predicate <var>pred</var>);  </code></pre>
_______________________________________________
Boost-commit mailing list
Boost-commit@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-commit


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic