Opened 12 years ago
Closed 11 years ago
#5418 closed Bugs (fixed)
Error in asio example: tick_count_timer
Reported by: | Peter Grimstrup | Owned by: | chris_kohlhoff |
---|---|---|---|
Milestone: | To Be Determined | Component: | asio |
Version: | Boost 1.47.0 | Severity: | Problem |
Keywords: | Cc: |
Description
The method less_than(t1, t2) returns true if called with t1 == t2.
static bool less_than(const time_type& t1, const time_type& t2) { return (t2.ticks_ - t1.ticks_) < static_cast<DWORD>(1 << 31); }
I suggest replacing with the correct (and maybe a bit more efficient):
static bool less_than(const time_type& t1, const time_type& t2) { return (static_cast<long>(t2.ticks_) - static_cast<long>(t1.ticks_)) > 0; }
Attachments (1)
Change History (3)
by , 12 years ago
Attachment: | tick_count_timer.cpp added |
---|
comment:1 by , 12 years ago
I've discovered a more serious problem. Methods tick_count_traits::subtract will return a large overflow value if t2 > t1. This happens periodically in the timer_queue and causes the timer to stop working for a long period of time.
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.
comment:2 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Fixed in release branch as of [72428].
Updated example file: tick_count_timer.cpp