Boost C++ Libraries: Ticket #5418: Error in asio example: tick_count_timer https://svn.boost.org/trac10/ticket/5418 <p> The method less_than(t1, t2) returns true if called with t1 == t2. </p> <pre class="wiki">static bool less_than(const time_type&amp; t1, const time_type&amp; t2) { return (t2.ticks_ - t1.ticks_) &lt; static_cast&lt;DWORD&gt;(1 &lt;&lt; 31); } </pre><p> I suggest replacing with the correct (and maybe a bit more efficient): </p> <pre class="wiki">static bool less_than(const time_type&amp; t1, const time_type&amp; t2) { return (static_cast&lt;long&gt;(t2.ticks_) - static_cast&lt;long&gt;(t1.ticks_)) &gt; 0; } </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5418 Trac 1.4.3 Ross MacGregor <gordonrossmacgregor@…> Wed, 13 Apr 2011 23:30:10 GMT attachment set https://svn.boost.org/trac10/ticket/5418 https://svn.boost.org/trac10/ticket/5418 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">tick_count_timer.cpp</span> </li> </ul> <p> Updated example file: tick_count_timer.cpp </p> Ticket Ross MacGregor <gordonrossmacgregor@…> Wed, 13 Apr 2011 23:32:16 GMT <link>https://svn.boost.org/trac10/ticket/5418#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5418#comment:1</guid> <description> <p> I've discovered a more serious problem. Methods tick_count_traits::subtract will return a large overflow value if t2 &gt; t1. This happens periodically in the timer_queue and causes the timer to stop working for a long period of time. </p> <p> I've attached my solution to the problem. Basically, I changed duration_type to be a signed value that is reflected in the call to the method to_posix_duration. It may be possible to reduce my subtract method to something less complicated. I've also included a small test for tick_count_traits in the example. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>chris_kohlhoff</dc:creator> <pubDate>Mon, 06 Jun 2011 01:31:15 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/5418#comment:2 https://svn.boost.org/trac10/ticket/5418#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> Fixed in release branch as of <a class="changeset" href="https://svn.boost.org/trac10/changeset/72428" title="Merge asio from trunk.">[72428]</a>. </p> Ticket