Changeset 167263 in webkit
- Timestamp:
- Apr 14, 2014 1:31:45 PM (10 years ago)
- Location:
- trunk/Source/WTF
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r167220 r167263 1 2014-04-14 Mark Lam <mark.lam@apple.com> 2 3 monotonicallyIncreasingTime() should only initialize its static timebaseInfo once. 4 <https://webkit.org/b/131630> 5 6 Reviewed by Filip Pizlo. 7 8 The current initialization of the static field is not thread safe. 9 10 * wtf/CurrentTime.cpp: 11 (WTF::monotonicallyIncreasingTime): 12 1 13 2014-04-14 Benjamin Poulain <benjamin@webkit.org> 2 14 -
trunk/Source/WTF/wtf/CurrentTime.cpp
r167101 r167263 38 38 #include <mach/mach.h> 39 39 #include <mach/mach_time.h> 40 #include <mutex> 40 41 #include <sys/time.h> 41 42 #elif OS(WINDOWS) … … 272 273 double monotonicallyIncreasingTime() 273 274 { 274 // Based on listing #2 from Apple QA 1398 .275 // Based on listing #2 from Apple QA 1398, but modified to be thread-safe. 275 276 static mach_timebase_info_data_t timebaseInfo; 276 if (!timebaseInfo.denom) { 277 static std::once_flag initializeTimerOnceFlag; 278 std::call_once(initializeTimerOnceFlag, [] { 277 279 kern_return_t kr = mach_timebase_info(&timebaseInfo); 278 280 ASSERT_UNUSED(kr, kr == KERN_SUCCESS); 279 } 281 ASSERT(timebaseInfo.denom); 282 }); 283 280 284 return (mach_absolute_time() * timebaseInfo.numer) / (1.0e9 * timebaseInfo.denom); 281 285 }
Note: See TracChangeset
for help on using the changeset viewer.