Skip to content

Commit

Permalink
Fixes ticket #12744 ("winapi::set_timer_resolution inadvertently chan…
Browse files Browse the repository at this point in the history
…ges timer resolution (Windows)")
  • Loading branch information
igaztanaga committed Jan 19, 2017
1 parent acce62f commit b3dd777
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions include/boost/interprocess/detail/os_thread_functions.hpp
Expand Up @@ -112,17 +112,17 @@ inline bool equal_thread_id(OS_thread_id_t id1, OS_thread_id_t id2)
//return the system tick in ns
inline unsigned long get_system_tick_ns()
{
unsigned long curres;
winapi::set_timer_resolution(10000, 0, &curres);
unsigned long curres, ignore1, ignore2;
winapi::query_timer_resolution(&ignore1, &ignore2, &curres);
//Windows API returns the value in hundreds of ns
return (curres - 1ul)*100ul;
}

//return the system tick in us
inline unsigned long get_system_tick_us()
{
unsigned long curres;
winapi::set_timer_resolution(10000, 0, &curres);
unsigned long curres, ignore1, ignore2;
winapi::query_timer_resolution(&ignore1, &ignore2, &curres);
//Windows API returns the value in hundreds of ns
return (curres - 1ul)/10ul + 1ul;
}
Expand All @@ -132,8 +132,8 @@ typedef unsigned __int64 OS_highres_count_t;
inline unsigned long get_system_tick_in_highres_counts()
{
__int64 freq;
unsigned long curres;
winapi::set_timer_resolution(10000, 0, &curres);
unsigned long curres, ignore1, ignore2;
winapi::query_timer_resolution(&ignore1, &ignore2, &curres);
//Frequency in counts per second
if(!winapi::query_performance_frequency(&freq)){
//Tick resolution in ms
Expand Down

0 comments on commit b3dd777

Please sign in to comment.