From 3f8290b4a13c15cf62776aa427f62a8ae77ee07c Mon Sep 17 00:00:00 2001 From: beware Date: Thu, 26 Oct 2017 02:16:06 +0000 Subject: [PATCH] no longer by default call TimeBeginPeriod(1) in btime init git-svn-id: file:///svnroot/lcore/trunk@150 b1de8a11-f9be-4011-bde0-cc7ace90066a --- btime.pas | 17 ++++++++++++++++- lcoreconfig.inc | 7 +++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/btime.pas b/btime.pas index 8218e64..87801b5 100644 --- a/btime.pas +++ b/btime.pas @@ -12,6 +12,9 @@ unit btime; {$ifdef fpc} {$mode delphi} {$endif} + +{$include lcoreconfig.inc} + interface {$ifdef mswindows} @@ -57,6 +60,9 @@ function timestrshort(i:tunixtimeint):string; // Wed Aug 15 16:21:09 2012 function timestriso(i:tunixtimeint):string; // 2012-08-15 16:21:09 function timestrisoutc(i:float):string; // 2012-08-15T14:21:09.255553Z +procedure beginhightimerrate; +procedure endhightimerrate; + {$ifdef mswindows} function unixtimefloat_systemtime:float; {$endif} @@ -762,10 +768,19 @@ begin end; +procedure beginhightimerrate; +begin + {$ifdef mswindows}timebeginperiod(1);{$endif} +end; + +procedure endhightimerrate; +begin + {$ifdef mswindows}timeendperiod(1);{$endif} +end; procedure init; begin - {$ifdef mswindows}timebeginperiod(1);{$endif} //ensure stable unchanging clock + {$ifdef btimehighrate}beginhightimerrate;{$endif} fillchar(mmtime_driftavg,sizeof(mmtime_driftavg),0); settimebias := 0; gettimezone; diff --git a/lcoreconfig.inc b/lcoreconfig.inc index 39d1f27..fbf9b6d 100644 --- a/lcoreconfig.inc +++ b/lcoreconfig.inc @@ -43,3 +43,10 @@ after running for a period of time. -anders} {$ifdef mswindows} {-$define winasyncdns} {$endif} + +{-------------------------------------------------------------------------------------} +{btime used to set TimeBeginPeriod(1) on init, so a program was permanently in this state. +doing this is not recommended, so it is no longer done by default. +set this define to get the old behavior back.} +{-$define btimehighrate} + -- 2.30.2