Changeset 156 for MicroThreading/UPlatform.pas
- Timestamp:
- Jan 28, 2011, 2:12:42 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
MicroThreading/UPlatform.pas
r149 r156 8 8 {$IFDEF Windows}Windows,{$ENDIF} 9 9 {$IFDEF Linux}BaseUnix, UnixUtil, Unix,{$ENDIF} 10 Classes, SysUtils, DateUtils ;10 Classes, SysUtils, DateUtils, SyncObjs; 11 11 12 12 function NowPrecise: TDateTime; … … 20 20 {$ENDIF} 21 21 22 var 23 NowPreciseLock: TCriticalSection; 22 24 23 25 function NowPrecise: TDateTime; … … 26 28 {$IFDEF Windows}TimerValue: Int64;{$ENDIF} 27 29 begin 28 {$IFDEF Windows} 29 QueryPerformanceCounter(TimerValue); 30 //Result := Int64(TimeStampToMSecs(DateTimeToTimeStamp(Now)) * 1000) // an alternative Win32 timebase 31 Result := TimerValue / PerformanceFrequency; 32 {$ENDIF} 30 try 31 NowPreciseLock.Acquire; 32 {$IFDEF Windows} 33 QueryPerformanceCounter(TimerValue); 34 //Result := Int64(TimeStampToMSecs(DateTimeToTimeStamp(Now)) * 1000) // an alternative Win32 timebase 35 Result := TimerValue / PerformanceFrequency; 36 {$ENDIF} 33 37 34 {$IFDEF Linux}35 fpgettimeofday(@t, nil);36 // Build a 64 bit microsecond tick from the seconds and microsecond longints37 Result := t.tv_sec + t.tv_usec / 1000000;38 {$ENDIF}38 {$IFDEF Linux} 39 fpgettimeofday(@t, nil); 40 // Build a 64 bit microsecond tick from the seconds and microsecond longints 41 Result := t.tv_sec + t.tv_usec / 1000000; 42 {$ENDIF} 39 43 40 Result := (Trunc(Now / OneSecond) + Frac(Result)) * OneSecond; 44 Result := (Trunc(Now / OneSecond) + Frac(Result)) * OneSecond; 45 finally 46 NowPreciseLock.Release; 47 end; 41 48 end; 42 49 … … 58 65 QueryPerformanceFrequency(PerformanceFrequency); 59 66 {$ENDIF} 67 NowPreciseLock := TCriticalSection.Create; 68 69 finalization 70 71 NowPreciseLock.Free; 60 72 61 73 end.
Note:
See TracChangeset
for help on using the changeset viewer.