Changeset 208415 in webkit
- Timestamp:
- Nov 4, 2016 8:02:39 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 11 added
- 52 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r208413 r208415 1 2016-11-04 Filip Pizlo <fpizlo@apple.com> 2 3 WTF::ParkingLot should stop using std::chrono because std::chrono::duration casts are prone to overflows 4 https://bugs.webkit.org/show_bug.cgi?id=152045 5 6 Reviewed by Andy Estes. 7 8 Probably the nicest example of why this patch is a good idea is the change in 9 AtomicsObject.cpp. 10 11 * jit/ICStats.cpp: 12 (JSC::ICStats::ICStats): 13 * runtime/AtomicsObject.cpp: 14 (JSC::atomicsFuncWait): 15 1 16 2016-11-04 JF Bastien <jfbastien@apple.com> 2 17 -
trunk/Source/JavaScriptCore/jit/ICStats.cpp
r199140 r208415 64 64 LockHolder locker(m_lock); 65 65 for (;;) { 66 m_condition.waitForSeconds(m_lock, 1, [this] () -> bool { return m_shouldStop; }); 66 m_condition.waitFor( 67 m_lock, Seconds(1), [this] () -> bool { return m_shouldStop; }); 67 68 if (m_shouldStop) 68 69 break; -
trunk/Source/JavaScriptCore/runtime/AtomicsObject.cpp
r208306 r208415 305 305 } 306 306 307 double timeoutInNanoseconds = timeoutInMilliseconds * 1000 * 1000;307 Seconds timeout = Seconds::fromMilliseconds(timeoutInMilliseconds); 308 308 309 309 // This covers the proposed rule: … … 315 315 // exec->argument(3) returns undefined if it's not provided and ToNumber(undefined) returns NaN, 316 316 // so NaN is the only special case. 317 if (timeout InNanoseconds == timeoutInNanoseconds)318 timeout InNanoseconds = std::max(0., timeoutInNanoseconds);317 if (timeout == timeout) 318 timeout = std::max(Seconds(0), timeout); 319 319 else 320 timeoutInNanoseconds = std::numeric_limits<double>::infinity(); 321 322 // What happens next is a pile of nonsense, but it's all needed because of corner cases 323 // inside std::chrono. 324 // FIXME: Stop using std::chrono. 325 326 ParkingLot::Clock::time_point timeout; 327 if (timeoutInNanoseconds > static_cast<double>(std::numeric_limits<int64_t>::max())) 328 timeout = ParkingLot::Clock::time_point::max(); 329 else { 330 std::chrono::nanoseconds relativeTimeout = 331 std::chrono::nanoseconds(static_cast<int64_t>(timeoutInNanoseconds)); 332 if (relativeTimeout < std::chrono::nanoseconds::zero()) 333 timeout = ParkingLot::Clock::now(); 334 else if (relativeTimeout > ParkingLot::Clock::duration::max()) 335 timeout = ParkingLot::Clock::time_point::max(); 336 else { 337 ParkingLot::Clock::duration myRelativeTimeout = 338 std::chrono::duration_cast<ParkingLot::Clock::duration>(relativeTimeout); 339 timeout = ParkingLot::Clock::now() + myRelativeTimeout; 340 } 341 } 320 timeout = Seconds::infinity(); 342 321 343 322 bool didPassValidation = false; … … 352 331 }, 353 332 [] () { }, 354 timeout);333 MonotonicTime::now() + timeout); 355 334 } 356 335 const char* resultString; -
trunk/Source/WTF/ChangeLog
r208373 r208415 1 2016-11-04 Filip Pizlo <fpizlo@apple.com> 2 3 WTF::ParkingLot should stop using std::chrono because std::chrono::duration casts are prone to overflows 4 https://bugs.webkit.org/show_bug.cgi?id=152045 5 6 Reviewed by Andy Estes. 7 8 We used to use 'double' for all time measurements. Sometimes it was milliseconds, 9 sometimes it was seconds. Sometimes we measured a span of time, sometimes we spoke of time 10 since some epoch. When we spoke of time since epoch, we either used a monotonic clock or 11 a wall clock. The type - always 'double' - never told us what kind of time we had, even 12 though there were roughly six of them (sec interval, ms interval, sec since epoch on wall, 13 ms since epoch on wall, sec since epoch monotonic, ms since epoch monotonic). 14 15 At some point, we thought that it would be a good idea to replace these doubles with 16 std::chrono. But since replacing some things with std::chrono, we found it to be terribly 17 inconvenient: 18 19 - Outrageous API. I never want to say std::chrono::milliseconds(blah). I never want to say 20 std::chrono::steady_clock::timepoint. The syntax for duration_cast is ugly, and ideally 21 duration_cast would not even be a thing. 22 23 - No overflow protection. std::chrono uses integers by default and using anything else is 24 clumsy. But the integer math is done without regard for the rough edges of integer math, 25 so any cast between std::chrono types risks overflow. Any comparison risks overflow 26 because it may do conversions silently. We have even found bugs where some C++ 27 implementations had more overflows than others, which ends up being a special kind of 28 hell. In many cases, the overflow also has nasal demons. 29 30 It's an error to represent time using integers. It would have been excusable back when 31 floating point math was not guaranteed to be supported on all platforms, but that would 32 have been a long time ago. Time is a continuous, infinite concept and it's a perfect fit 33 for floating point: 34 35 - Floating point preserves precision under multiplication in all but extreme cases, so 36 using floating point for time means that unit conversions are almost completely 37 lossless. This means that we don't have to think very hard about what units to use. In 38 this patch, we use seconds almost everywhere. We only convert at boundaries, like an API 39 boundary that wants something other than seconds. 40 41 - Floating point makes it easy to reason about infinity, which is something that time code 42 wants to do a lot. Example: when would you like to timeout? Infinity please! This is the 43 most elegant way of having an API support both a timeout variant and a no-timeout 44 variant. 45 46 - Floating point does well-understood things when math goes wrong, and these things are 47 pretty well optimized to match what a mathematician would do when computing with real 48 numbers represented using scientific notation with a finite number of significant 49 digits. This means that time math under floating point looks like normal math. On the 50 other hand, std::chrono time math looks like garbage because you have to always check 51 for multiple possible UB corners whenever you touch large integers. Integers that 52 represent time are very likely to be large and you don't have to do much to overflow 53 them. At this time, based on the number of bugs we have already seen due to chrono 54 overflows, I am not certain that we even understand what are all of the corner cases 55 that we should even check for. 56 57 This patch introduces a new set of timekeeping classes that are all based on double, and 58 all internally use seconds. These classes support algebraic typing. The classes are: 59 60 - Seconds: this is for measuring a duration. 61 - WallTime: time since epoch according to a wall clock (aka real time clock). 62 - MonotonicTime: time since epoch according to a monotonic clock. 63 - ClockType: enum that says either Wall or Monotonic. 64 - TimeWithDynamicClockType: a tuple of double and ClockType, which represents either a 65 wall time or a monotonic time. 66 67 All of these classes behave like C++ values and are cheap to copy around since they are 68 very nearly POD. This supports comprehensive conversions between the various time types. 69 Most of this is by way of algebra. Here are just some of the rules we recognize: 70 71 WallTime = WallTime + Seconds 72 Seconds = WallTime - WallTime 73 MonotonicTime = MonotonicTime + Seconds 74 etc... 75 76 We support negative, infinite, and NaN times because math. 77 78 We support conversions between MonotonicTime and WallTime, like: 79 80 WallTime wt = mt.approximateWallTime() 81 82 This is called this "approximate" because the only way to do it is to get the current time 83 on both clocks and convert relative to that. 84 85 Many of our APIs would be happy using whatever notion of time the user wanted to use. For 86 those APIs, which includes Condition and ParkingLot, we have TimeWithDynamicClockType. You 87 can automatically convert WallTime or MonotonicTime to TimeWithDynamicClockType. This 88 means that if you use a WallTime with Condition::waitUntil, then Condition's internal 89 logic for when it should wake up makes its decision based on the current WallTime - but if 90 you use MonotonicTime then waitUntil will make its decision based on current 91 MonotonicTime. This is a greater level of flexibility than chrono allowed, since chrono 92 did not have the concept of a dynamic clock type. 93 94 This patch does not include conversions between std::chrono and these new time classes, 95 because past experience shows that we're quite bad at getting conversions between 96 std::chrono and anything else right. Also, I didn't need such conversion code because this 97 patch only converts code that transitively touches ParkingLot and Condition. It was easy 98 to get all of that code onto the new time classes. 99 100 * WTF.xcodeproj/project.pbxproj: 101 * wtf/AutomaticThread.cpp: 102 (WTF::AutomaticThread::start): 103 * wtf/CMakeLists.txt: 104 * wtf/ClockType.cpp: Added. 105 (WTF::printInternal): 106 * wtf/ClockType.h: Added. 107 * wtf/Condition.h: 108 (WTF::ConditionBase::waitUntil): 109 (WTF::ConditionBase::waitFor): 110 (WTF::ConditionBase::wait): 111 (WTF::ConditionBase::waitUntilWallClockSeconds): Deleted. 112 (WTF::ConditionBase::waitUntilMonotonicClockSeconds): Deleted. 113 (WTF::ConditionBase::waitForSeconds): Deleted. 114 (WTF::ConditionBase::waitForSecondsImpl): Deleted. 115 (WTF::ConditionBase::waitForImpl): Deleted. 116 (WTF::ConditionBase::absoluteFromRelative): Deleted. 117 * wtf/CrossThreadQueue.h: 118 (WTF::CrossThreadQueue<DataType>::waitForMessage): 119 * wtf/CurrentTime.cpp: 120 (WTF::sleep): 121 * wtf/MessageQueue.h: 122 (WTF::MessageQueue::infiniteTime): Deleted. 123 * wtf/MonotonicTime.cpp: Added. 124 (WTF::MonotonicTime::now): 125 (WTF::MonotonicTime::approximateWallTime): 126 (WTF::MonotonicTime::dump): 127 (WTF::MonotonicTime::sleep): 128 * wtf/MonotonicTime.h: Added. 129 (WTF::MonotonicTime::MonotonicTime): 130 (WTF::MonotonicTime::fromRawDouble): 131 (WTF::MonotonicTime::infinity): 132 (WTF::MonotonicTime::secondsSinceEpoch): 133 (WTF::MonotonicTime::approximateMonotonicTime): 134 (WTF::MonotonicTime::operator bool): 135 (WTF::MonotonicTime::operator+): 136 (WTF::MonotonicTime::operator-): 137 (WTF::MonotonicTime::operator+=): 138 (WTF::MonotonicTime::operator-=): 139 (WTF::MonotonicTime::operator==): 140 (WTF::MonotonicTime::operator!=): 141 (WTF::MonotonicTime::operator<): 142 (WTF::MonotonicTime::operator>): 143 (WTF::MonotonicTime::operator<=): 144 (WTF::MonotonicTime::operator>=): 145 * wtf/ParkingLot.cpp: 146 (WTF::ParkingLot::parkConditionallyImpl): 147 (WTF::ParkingLot::unparkOne): 148 (WTF::ParkingLot::unparkOneImpl): 149 (WTF::ParkingLot::unparkCount): 150 * wtf/ParkingLot.h: 151 (WTF::ParkingLot::parkConditionally): 152 (WTF::ParkingLot::compareAndPark): 153 * wtf/Seconds.cpp: Added. 154 (WTF::Seconds::operator+): 155 (WTF::Seconds::operator-): 156 (WTF::Seconds::dump): 157 (WTF::Seconds::sleep): 158 * wtf/Seconds.h: Added. 159 (WTF::Seconds::Seconds): 160 (WTF::Seconds::value): 161 (WTF::Seconds::seconds): 162 (WTF::Seconds::milliseconds): 163 (WTF::Seconds::microseconds): 164 (WTF::Seconds::nanoseconds): 165 (WTF::Seconds::fromMilliseconds): 166 (WTF::Seconds::fromMicroseconds): 167 (WTF::Seconds::fromNanoseconds): 168 (WTF::Seconds::infinity): 169 (WTF::Seconds::operator bool): 170 (WTF::Seconds::operator+): 171 (WTF::Seconds::operator-): 172 (WTF::Seconds::operator*): 173 (WTF::Seconds::operator/): 174 (WTF::Seconds::operator+=): 175 (WTF::Seconds::operator-=): 176 (WTF::Seconds::operator*=): 177 (WTF::Seconds::operator/=): 178 (WTF::Seconds::operator==): 179 (WTF::Seconds::operator!=): 180 (WTF::Seconds::operator<): 181 (WTF::Seconds::operator>): 182 (WTF::Seconds::operator<=): 183 (WTF::Seconds::operator>=): 184 * wtf/TimeWithDynamicClockType.cpp: Added. 185 (WTF::TimeWithDynamicClockType::now): 186 (WTF::TimeWithDynamicClockType::nowWithSameClock): 187 (WTF::TimeWithDynamicClockType::wallTime): 188 (WTF::TimeWithDynamicClockType::monotonicTime): 189 (WTF::TimeWithDynamicClockType::approximateWallTime): 190 (WTF::TimeWithDynamicClockType::approximateMonotonicTime): 191 (WTF::TimeWithDynamicClockType::operator-): 192 (WTF::TimeWithDynamicClockType::operator<): 193 (WTF::TimeWithDynamicClockType::operator>): 194 (WTF::TimeWithDynamicClockType::operator<=): 195 (WTF::TimeWithDynamicClockType::operator>=): 196 (WTF::TimeWithDynamicClockType::dump): 197 (WTF::TimeWithDynamicClockType::sleep): 198 * wtf/TimeWithDynamicClockType.h: Added. 199 (WTF::TimeWithDynamicClockType::TimeWithDynamicClockType): 200 (WTF::TimeWithDynamicClockType::fromRawDouble): 201 (WTF::TimeWithDynamicClockType::secondsSinceEpoch): 202 (WTF::TimeWithDynamicClockType::clockType): 203 (WTF::TimeWithDynamicClockType::withSameClockAndRawDouble): 204 (WTF::TimeWithDynamicClockType::operator bool): 205 (WTF::TimeWithDynamicClockType::operator+): 206 (WTF::TimeWithDynamicClockType::operator-): 207 (WTF::TimeWithDynamicClockType::operator+=): 208 (WTF::TimeWithDynamicClockType::operator-=): 209 (WTF::TimeWithDynamicClockType::operator==): 210 (WTF::TimeWithDynamicClockType::operator!=): 211 * wtf/WallTime.cpp: Added. 212 (WTF::WallTime::now): 213 (WTF::WallTime::approximateMonotonicTime): 214 (WTF::WallTime::dump): 215 (WTF::WallTime::sleep): 216 * wtf/WallTime.h: Added. 217 (WTF::WallTime::WallTime): 218 (WTF::WallTime::fromRawDouble): 219 (WTF::WallTime::infinity): 220 (WTF::WallTime::secondsSinceEpoch): 221 (WTF::WallTime::approximateWallTime): 222 (WTF::WallTime::operator bool): 223 (WTF::WallTime::operator+): 224 (WTF::WallTime::operator-): 225 (WTF::WallTime::operator+=): 226 (WTF::WallTime::operator-=): 227 (WTF::WallTime::operator==): 228 (WTF::WallTime::operator!=): 229 (WTF::WallTime::operator<): 230 (WTF::WallTime::operator>): 231 (WTF::WallTime::operator<=): 232 (WTF::WallTime::operator>=): 233 * wtf/threads/BinarySemaphore.cpp: 234 (WTF::BinarySemaphore::wait): 235 * wtf/threads/BinarySemaphore.h: 236 1 237 2016-11-03 Filip Pizlo <fpizlo@apple.com> 2 238 -
trunk/Source/WTF/WTF.xcodeproj/project.pbxproj
r207480 r208415 30 30 0F4570431BE5B58F0062A629 /* Dominators.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F4570421BE5B58F0062A629 /* Dominators.h */; }; 31 31 0F4570451BE834410062A629 /* BubbleSort.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F4570441BE834410062A629 /* BubbleSort.h */; }; 32 0F66B28A1DC97BAB004A1D3F /* ClockType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F66B2801DC97BAB004A1D3F /* ClockType.cpp */; }; 33 0F66B28B1DC97BAB004A1D3F /* ClockType.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F66B2811DC97BAB004A1D3F /* ClockType.h */; }; 34 0F66B28C1DC97BAB004A1D3F /* MonotonicTime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F66B2821DC97BAB004A1D3F /* MonotonicTime.cpp */; }; 35 0F66B28D1DC97BAB004A1D3F /* MonotonicTime.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F66B2831DC97BAB004A1D3F /* MonotonicTime.h */; }; 36 0F66B28E1DC97BAB004A1D3F /* Seconds.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F66B2841DC97BAB004A1D3F /* Seconds.cpp */; }; 37 0F66B28F1DC97BAB004A1D3F /* Seconds.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F66B2851DC97BAB004A1D3F /* Seconds.h */; }; 38 0F66B2901DC97BAB004A1D3F /* TimeWithDynamicClockType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F66B2861DC97BAB004A1D3F /* TimeWithDynamicClockType.cpp */; }; 39 0F66B2911DC97BAB004A1D3F /* TimeWithDynamicClockType.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F66B2871DC97BAB004A1D3F /* TimeWithDynamicClockType.h */; }; 40 0F66B2921DC97BAB004A1D3F /* WallTime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F66B2881DC97BAB004A1D3F /* WallTime.cpp */; }; 41 0F66B2931DC97BAB004A1D3F /* WallTime.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F66B2891DC97BAB004A1D3F /* WallTime.h */; }; 32 42 0F725CAC1C50461600AD943A /* RangeSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F725CAB1C50461600AD943A /* RangeSet.h */; }; 33 43 0F7C5FB61D885CF20044F5E2 /* FastBitVector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F7C5FB51D885CF20044F5E2 /* FastBitVector.cpp */; }; … … 373 383 0F4570421BE5B58F0062A629 /* Dominators.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Dominators.h; sourceTree = "<group>"; }; 374 384 0F4570441BE834410062A629 /* BubbleSort.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BubbleSort.h; sourceTree = "<group>"; }; 385 0F66B2801DC97BAB004A1D3F /* ClockType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ClockType.cpp; sourceTree = "<group>"; }; 386 0F66B2811DC97BAB004A1D3F /* ClockType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClockType.h; sourceTree = "<group>"; }; 387 0F66B2821DC97BAB004A1D3F /* MonotonicTime.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MonotonicTime.cpp; sourceTree = "<group>"; }; 388 0F66B2831DC97BAB004A1D3F /* MonotonicTime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MonotonicTime.h; sourceTree = "<group>"; }; 389 0F66B2841DC97BAB004A1D3F /* Seconds.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Seconds.cpp; sourceTree = "<group>"; }; 390 0F66B2851DC97BAB004A1D3F /* Seconds.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Seconds.h; sourceTree = "<group>"; }; 391 0F66B2861DC97BAB004A1D3F /* TimeWithDynamicClockType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TimeWithDynamicClockType.cpp; sourceTree = "<group>"; }; 392 0F66B2871DC97BAB004A1D3F /* TimeWithDynamicClockType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TimeWithDynamicClockType.h; sourceTree = "<group>"; }; 393 0F66B2881DC97BAB004A1D3F /* WallTime.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WallTime.cpp; sourceTree = "<group>"; }; 394 0F66B2891DC97BAB004A1D3F /* WallTime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WallTime.h; sourceTree = "<group>"; }; 375 395 0F725CAB1C50461600AD943A /* RangeSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RangeSet.h; sourceTree = "<group>"; }; 376 396 0F7C5FB51D885CF20044F5E2 /* FastBitVector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FastBitVector.cpp; sourceTree = "<group>"; }; … … 864 884 A8A4726A151A825A004123FF /* CheckedArithmetic.h */, 865 885 A8A4726B151A825A004123FF /* CheckedBoolean.h */, 886 0F66B2801DC97BAB004A1D3F /* ClockType.cpp */, 887 0F66B2811DC97BAB004A1D3F /* ClockType.h */, 866 888 0FC4EDE51696149600F65041 /* CommaPrinter.h */, 867 889 0F8F2B8F172E00F0007DBDA5 /* CompilationThread.cpp */, … … 947 969 A8A472CE151A825B004123FF /* MetaAllocator.h */, 948 970 A8A472CF151A825B004123FF /* MetaAllocatorHandle.h */, 971 0F66B2821DC97BAB004A1D3F /* MonotonicTime.cpp */, 972 0F66B2831DC97BAB004A1D3F /* MonotonicTime.h */, 949 973 FE8225301B2A1E5B00BA68FD /* NakedPtr.h */, 950 974 1A3F6BE6174ADA2100B2EEA7 /* NeverDestroyed.h */, … … 1008 1032 1A3524AA1D63A2FF0031729B /* Scope.h */, 1009 1033 0FEC84B01BDACD390080FF74 /* ScopedLambda.h */, 1034 0F66B2841DC97BAB004A1D3F /* Seconds.cpp */, 1035 0F66B2851DC97BAB004A1D3F /* Seconds.h */, 1010 1036 A8A47306151A825B004123FF /* SegmentedVector.h */, 1011 1037 A8A47307151A825B004123FF /* SentinelLinkedList.h */, … … 1044 1070 A8A4733E151A825B004123FF /* ThreadSafeRefCounted.h */, 1045 1071 A8A4733F151A825B004123FF /* ThreadSpecific.h */, 1072 0F66B2861DC97BAB004A1D3F /* TimeWithDynamicClockType.cpp */, 1073 0F66B2871DC97BAB004A1D3F /* TimeWithDynamicClockType.h */, 1046 1074 553071C91C40427200384898 /* TinyLRUCache.h */, 1047 1075 0FED67B51B22D4D80066CE15 /* TinyPtrSet.h */, … … 1055 1083 A8A47371151A825B004123FF /* VectorTraits.h */, 1056 1084 A8A47372151A825B004123FF /* VMTags.h */, 1085 0F66B2881DC97BAB004A1D3F /* WallTime.cpp */, 1086 0F66B2891DC97BAB004A1D3F /* WallTime.h */, 1057 1087 974CFC8D16A4F327006D5404 /* WeakPtr.h */, 1058 1088 0F3501631BB258C800F0A2A3 /* WeakRandom.h */, … … 1260 1290 0FB14E1B1810E1DC009B6B4D /* BagToHashMap.h in Headers */, 1261 1291 8134013915B092FD001FF0B8 /* Base64.h in Headers */, 1292 0F66B28F1DC97BAB004A1D3F /* Seconds.h in Headers */, 1262 1293 A8A473A9151A825B004123FF /* bignum-dtoa.h in Headers */, 1294 0F66B2911DC97BAB004A1D3F /* TimeWithDynamicClockType.h in Headers */, 1263 1295 A8A473AB151A825B004123FF /* bignum.h in Headers */, 1264 1296 A8A47452151A825B004123FF /* BinarySemaphore.h in Headers */, … … 1341 1373 539EB0631D55284200C82EF7 /* LEBDecoder.h in Headers */, 1342 1374 A70DA0851799F04D00529A9B /* ListDump.h in Headers */, 1375 0F66B2931DC97BAB004A1D3F /* WallTime.h in Headers */, 1343 1376 A8A473E1151A825B004123FF /* ListHashSet.h in Headers */, 1344 1377 0FE1646B1B6FFC9600400E7C /* Lock.h in Headers */, … … 1400 1433 1469419616EAAFF80024E146 /* SchedulePair.h in Headers */, 1401 1434 1A3524AB1D63A2FF0031729B /* Scope.h in Headers */, 1435 0F66B28D1DC97BAB004A1D3F /* MonotonicTime.h in Headers */, 1402 1436 0FEC84B11BDACD390080FF74 /* ScopedLambda.h in Headers */, 1403 1437 A5098B021C16A4F900087797 /* SecuritySPI.h in Headers */, … … 1467 1501 A8A47446151A825B004123FF /* WTFString.h in Headers */, 1468 1502 A8A47487151A825B004123FF /* WTFThreadData.h in Headers */, 1503 0F66B28B1DC97BAB004A1D3F /* ClockType.h in Headers */, 1469 1504 CE73E02519DCB7AB00580D5C /* XPCSPI.h in Headers */, 1470 1505 C8B0E1A1E01A486EB95E0D11 /* IndexSet.h in Headers */, … … 1582 1617 A8A47451151A825B004123FF /* BinarySemaphore.cpp in Sources */, 1583 1618 A8A4738B151A825B004123FF /* BitVector.cpp in Sources */, 1619 0F66B2901DC97BAB004A1D3F /* TimeWithDynamicClockType.cpp in Sources */, 1584 1620 DCEE22011CEA7551000C2396 /* BlockObjCExceptions.mm in Sources */, 1585 1621 A8A473AC151A825B004123FF /* cached-powers.cc in Sources */, … … 1642 1678 0FDDBFA71666DFA300C55FEF /* StringPrintStream.cpp in Sources */, 1643 1679 A8A47443151A825B004123FF /* StringStatics.cpp in Sources */, 1680 0F66B28A1DC97BAB004A1D3F /* ClockType.cpp in Sources */, 1681 0F66B2921DC97BAB004A1D3F /* WallTime.cpp in Sources */, 1682 0F66B28E1DC97BAB004A1D3F /* Seconds.cpp in Sources */, 1644 1683 0F43D8F11DB5ADDC00108FB6 /* AutomaticThread.cpp in Sources */, 1645 1684 93F1993E19D7958D00C2390B /* StringView.cpp in Sources */, … … 1653 1692 A8A4744A151A825B004123FF /* Threading.cpp in Sources */, 1654 1693 A8A4744E151A825B004123FF /* ThreadingPthreads.cpp in Sources */, 1694 0F66B28C1DC97BAB004A1D3F /* MonotonicTime.cpp in Sources */, 1655 1695 1C181C8F1D307AB800F5FA16 /* UTextProvider.cpp in Sources */, 1656 1696 1C181C911D307AB800F5FA16 /* UTextProviderLatin1.cpp in Sources */, -
trunk/Source/WTF/wtf/AutomaticThread.cpp
r208306 r208415 181 181 RELEASE_ASSERT(result == PollResult::Wait); 182 182 // Shut the thread down after one second. 183 double timeout = monotonicallyIncreasingTime() + 1;184 183 bool awokenByNotify = 185 m_condition->m_condition.wait UntilMonotonicClockSeconds(*m_lock, timeout);184 m_condition->m_condition.waitFor(*m_lock, Seconds(1)); 186 185 if (!awokenByNotify) { 187 186 if (verbose) -
trunk/Source/WTF/wtf/CMakeLists.txt
r207480 r208415 13 13 BumpPointerAllocator.h 14 14 ByteOrder.h 15 ClockType.h 15 16 CompilationThread.h 16 17 Compiler.h … … 65 66 MetaAllocator.h 66 67 MetaAllocatorHandle.h 68 MonotonicTime.h 67 69 Noncopyable.h 68 70 NumberOfCores.h … … 102 104 SaturatedArithmetic.h 103 105 ScopedLambda.h 106 Seconds.h 104 107 SegmentedVector.h 105 108 SmallPtrSet.h … … 117 120 Threading.h 118 121 ThreadingPrimitives.h 122 TimeWithDynamicClockType.h 119 123 TinyPtrSet.h 120 124 UniqueRef.h … … 125 129 VectorTraits.h 126 130 WTFThreadData.h 131 WallTime.h 127 132 WeakPtr.h 128 133 WordLock.h … … 177 182 AutomaticThread.cpp 178 183 BitVector.cpp 184 ClockType.cpp 179 185 CompilationThread.cpp 180 186 CrossThreadCopier.cpp … … 196 202 MediaTime.cpp 197 203 MetaAllocator.cpp 204 MonotonicTime.cpp 198 205 NumberOfCores.cpp 199 206 OSRandomSource.cpp … … 208 215 RunLoop.cpp 209 216 SHA1.cpp 217 Seconds.cpp 210 218 SixCharacterHash.cpp 211 219 StackBounds.cpp … … 213 221 StringPrintStream.cpp 214 222 Threading.cpp 223 TimeWithDynamicClockType.cpp 215 224 WTFThreadData.cpp 225 WallTime.cpp 216 226 WordLock.cpp 217 227 WorkQueue.cpp -
trunk/Source/WTF/wtf/Condition.h
r207545 r208415 1 1 /* 2 * Copyright (C) 2015 Apple Inc. All rights reserved.2 * Copyright (C) 2015-2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 27 27 #define WTF_Condition_h 28 28 29 #include <chrono>30 29 #include <functional> 31 30 #include <wtf/CurrentTime.h> 32 31 #include <wtf/Noncopyable.h> 33 32 #include <wtf/ParkingLot.h> 33 #include <wtf/TimeWithDynamicClockType.h> 34 34 35 35 namespace WTF { … … 47 47 // Use Lock in instance variables. 48 48 struct ConditionBase { 49 typedef ParkingLot::Clock Clock; 49 // Condition will accept any kind of time and convert it internally, but this typedef tells 50 // you what kind of time Condition would be able to use without conversions. However, if you 51 // are unlikely to be affected by the cost of conversions, it is better to use MonotonicTime. 52 typedef ParkingLot::Time Time; 50 53 51 54 // Wait on a parking queue while releasing the given lock. It will unlock the lock just before … … 65 68 // documentation for timedwait(). 66 69 template<typename LockType> 67 bool waitUntil(LockType& lock, Clock::time_pointtimeout)70 bool waitUntil(LockType& lock, const TimeWithDynamicClockType& timeout) 68 71 { 69 72 bool result; 70 if (timeout < Clock::now()) {73 if (timeout < timeout.nowWithSameClock()) { 71 74 lock.unlock(); 72 75 result = false; … … 90 93 // May return early due to timeout. 91 94 template<typename LockType, typename Functor> 92 bool waitUntil(LockType& lock, Clock::time_point timeout, const Functor& predicate) 95 bool waitUntil( 96 LockType& lock, const TimeWithDynamicClockType& timeout, const Functor& predicate) 93 97 { 94 98 while (!predicate()) { … … 101 105 // Wait until the given predicate is satisfied. Returns true if it is satisfied in the end. 102 106 // May return early due to timeout. 103 template<typename LockType, typename DurationType, typenameFunctor>107 template<typename LockType, typename Functor> 104 108 bool waitFor( 105 LockType& lock, const DurationType&relativeTimeout, const Functor& predicate)109 LockType& lock, Seconds relativeTimeout, const Functor& predicate) 106 110 { 107 return waitUntil(lock, absoluteFromRelative(relativeTimeout), predicate); 111 return waitUntil(lock, MonotonicTime::now() + relativeTimeout, predicate); 112 } 113 114 template<typename LockType> 115 bool waitFor(LockType& lock, Seconds relativeTimeout) 116 { 117 return waitUntil(lock, MonotonicTime::now() + relativeTimeout); 108 118 } 109 119 … … 111 121 void wait(LockType& lock) 112 122 { 113 waitUntil(lock, Clock::time_point::max());123 waitUntil(lock, Time::infinity()); 114 124 } 115 125 … … 119 129 while (!predicate()) 120 130 wait(lock); 121 }122 123 template<typename LockType, typename TimeType>124 bool waitUntil(LockType& lock, const TimeType& timeout)125 {126 if (timeout == TimeType::max()) {127 wait(lock);128 return true;129 }130 return waitForImpl(lock, timeout - TimeType::clock::now());131 }132 133 template<typename LockType>134 bool waitUntilWallClockSeconds(LockType& lock, double absoluteTimeoutSeconds)135 {136 return waitForSecondsImpl(lock, absoluteTimeoutSeconds - currentTime());137 }138 139 template<typename LockType>140 bool waitUntilMonotonicClockSeconds(LockType& lock, double absoluteTimeoutSeconds)141 {142 return waitForSecondsImpl(lock, absoluteTimeoutSeconds - monotonicallyIncreasingTime());143 }144 145 template<typename LockType, typename Functor>146 bool waitForSeconds(LockType& lock, double relativeTimeoutSeconds, const Functor& predicate)147 {148 double relativeTimeoutNanoseconds = relativeTimeoutSeconds * (1000.0 * 1000.0 * 1000.0);149 150 if (!(relativeTimeoutNanoseconds > 0)) {151 // This handles insta-timeouts as well as NaN.152 lock.unlock();153 lock.lock();154 return false;155 }156 157 if (relativeTimeoutNanoseconds > static_cast<double>(std::numeric_limits<int64_t>::max())) {158 // If the timeout in nanoseconds cannot be expressed using a 64-bit integer, then we159 // might as well wait forever.160 wait(lock, predicate);161 return true;162 }163 164 auto relativeTimeout =165 std::chrono::nanoseconds(static_cast<int64_t>(relativeTimeoutNanoseconds));166 167 return waitFor(lock, relativeTimeout, predicate);168 131 } 169 132 … … 208 171 209 172 protected: 210 template<typename LockType>211 bool waitForSecondsImpl(LockType& lock, double relativeTimeoutSeconds)212 {213 double relativeTimeoutNanoseconds = relativeTimeoutSeconds * (1000.0 * 1000.0 * 1000.0);214 215 if (!(relativeTimeoutNanoseconds > 0)) {216 // This handles insta-timeouts as well as NaN.217 lock.unlock();218 lock.lock();219 return false;220 }221 222 if (relativeTimeoutNanoseconds > static_cast<double>(std::numeric_limits<int64_t>::max())) {223 // If the timeout in nanoseconds cannot be expressed using a 64-bit integer, then we224 // might as well wait forever.225 wait(lock);226 return true;227 }228 229 auto relativeTimeout =230 std::chrono::nanoseconds(static_cast<int64_t>(relativeTimeoutNanoseconds));231 232 return waitForImpl(lock, relativeTimeout);233 }234 235 template<typename LockType, typename DurationType>236 bool waitForImpl(LockType& lock, const DurationType& relativeTimeout)237 {238 return waitUntil(lock, absoluteFromRelative(relativeTimeout));239 }240 241 template<typename DurationType>242 Clock::time_point absoluteFromRelative(const DurationType& relativeTimeout)243 {244 if (relativeTimeout < DurationType::zero())245 return Clock::time_point::min();246 247 if (relativeTimeout > Clock::duration::max()) {248 // This is highly unlikely. But if it happens, we want to not do anything dumb. Sleeping249 // without a timeout seems sensible when the timeout duration is greater than what can be250 // expressed using steady_clock.251 return Clock::time_point::max();252 }253 254 Clock::duration myRelativeTimeout =255 std::chrono::duration_cast<Clock::duration>(relativeTimeout);256 257 return Clock::now() + myRelativeTimeout;258 }259 260 173 Atomic<bool> m_hasWaiters; 261 }; 174 }; 262 175 263 176 class Condition : public ConditionBase { -
trunk/Source/WTF/wtf/CrossThreadQueue.h
r201518 r208415 75 75 break; 76 76 77 static const double infiniteTime = std::numeric_limits<double>::max(); 78 m_condition.waitUntilWallClockSeconds(m_lock, infiniteTime); 77 m_condition.wait(m_lock); 79 78 } 80 79 -
trunk/Source/WTF/wtf/CurrentTime.cpp
r198364 r208415 1 1 /* 2 * Copyright (C) 2006 , 2008, 2009, 2010Apple Inc. All rights reserved.2 * Copyright (C) 2006-2016 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2008 Google Inc. All rights reserved. 4 4 * Copyright (C) 2007-2009 Torch Mobile, Inc. … … 341 341 Condition fakeCondition; 342 342 LockHolder fakeLocker(fakeLock); 343 fakeCondition.wait UntilMonotonicClockSeconds(fakeLock, monotonicallyIncreasingTime() + value);343 fakeCondition.waitFor(fakeLock, Seconds(value)); 344 344 } 345 345 -
trunk/Source/WTF/wtf/MessageQueue.h
r194496 r208415 1 1 /* 2 * Copyright (C) 2008, 2015 Apple Inc. All rights reserved.2 * Copyright (C) 2008, 2015-2016 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2009 Google Inc. All rights reserved. 4 4 * … … 38 38 #include <wtf/Noncopyable.h> 39 39 #include <wtf/Threading.h> 40 #include <wtf/WallTime.h> 40 41 41 42 namespace WTF { … … 66 67 std::unique_ptr<DataType> tryGetMessageIgnoringKilled(); 67 68 template<typename Predicate> 68 std::unique_ptr<DataType> waitForMessageFilteredWithTimeout(MessageQueueWaitResult&, Predicate&&, double absoluteTime);69 std::unique_ptr<DataType> waitForMessageFilteredWithTimeout(MessageQueueWaitResult&, Predicate&&, WallTime absoluteTime); 69 70 70 71 template<typename Predicate> … … 76 77 // The result of isEmpty() is only valid if no other thread is manipulating the queue at the same time. 77 78 bool isEmpty(); 78 79 static double infiniteTime() { return std::numeric_limits<double>::max(); }80 79 81 80 private: … … 131 130 { 132 131 MessageQueueWaitResult exitReason; 133 std::unique_ptr<DataType> result = waitForMessageFilteredWithTimeout(exitReason, [](const DataType&) { return true; }, infiniteTime());132 std::unique_ptr<DataType> result = waitForMessageFilteredWithTimeout(exitReason, [](const DataType&) { return true; }, WallTime::infinity()); 134 133 ASSERT(exitReason == MessageQueueTerminated || exitReason == MessageQueueMessageReceived); 135 134 return result; … … 138 137 template<typename DataType> 139 138 template<typename Predicate> 140 inline auto MessageQueue<DataType>::waitForMessageFilteredWithTimeout(MessageQueueWaitResult& result, Predicate&& predicate, double absoluteTime) -> std::unique_ptr<DataType>139 inline auto MessageQueue<DataType>::waitForMessageFilteredWithTimeout(MessageQueueWaitResult& result, Predicate&& predicate, WallTime absoluteTime) -> std::unique_ptr<DataType> 141 140 { 142 141 LockHolder lock(m_mutex); … … 152 151 break; 153 152 154 timedOut = !m_condition.waitUntil WallClockSeconds(m_mutex, absoluteTime);155 } 156 157 ASSERT(!timedOut || absoluteTime != infiniteTime());153 timedOut = !m_condition.waitUntil(m_mutex, absoluteTime); 154 } 155 156 ASSERT(!timedOut || absoluteTime != WallTime::infinity()); 158 157 159 158 if (m_killed) { -
trunk/Source/WTF/wtf/ParkingLot.cpp
r208306 r208415 55 55 ThreadIdentifier threadIdentifier; 56 56 57 std::mutex parkingLock;58 std::condition_variableparkingCondition;57 Mutex parkingLock; 58 ThreadCondition parkingCondition; 59 59 60 60 const void* address { nullptr }; … … 565 565 const ScopedLambda<bool()>& validation, 566 566 const ScopedLambda<void()>& beforeSleep, 567 Clock::time_pointtimeout)567 const TimeWithDynamicClockType& timeout) 568 568 { 569 569 if (verbose) … … 593 593 bool didGetDequeued; 594 594 { 595 std::unique_lock<std::mutex> locker(me->parkingLock); 596 while (me->address && Clock::now() < timeout) { 597 // Falling back to wait() works around a bug in libstdc++ implementation of std::condition_variable. See: 598 // - https://bugs.webkit.org/show_bug.cgi?id=148027 599 // - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58931 600 if (timeout == Clock::time_point::max()) 601 me->parkingCondition.wait(locker); 602 else 603 me->parkingCondition.wait_until(locker, timeout); 595 MutexLocker locker(me->parkingLock); 596 while (me->address && timeout.nowWithSameClock() < timeout) { 597 me->parkingCondition.timedWait( 598 me->parkingLock, timeout.approximateWallTime().secondsSinceEpoch().value()); 604 599 605 // Because of the above, we do this thing, which is hilariously awful, but ensures that the worst case is 606 // a CPU-eating spin but not a deadlock. 607 locker.unlock(); 608 locker.lock(); 600 // It's possible for the OS to decide not to wait. If it does that then it will also 601 // decide not to release the lock. If there's a bug in the time math, then this could 602 // result in a deadlock. Flashing the lock means that at worst it's just a CPU-eating 603 // spin. 604 me->parkingLock.unlock(); 605 me->parkingLock.lock(); 609 606 } 610 607 ASSERT(!me->address || me->address == address); … … 641 638 // Make sure that no matter what, me->address is null after this point. 642 639 { 643 std::unique_lock<std::mutex>locker(me->parkingLock);640 MutexLocker locker(me->parkingLock); 644 641 if (!didDequeue) { 645 642 // If we did not dequeue ourselves, then someone else did. They will set our address to … … 648 645 // other things. 649 646 while (me->address) 650 me->parkingCondition.wait( locker);647 me->parkingCondition.wait(me->parkingLock); 651 648 } 652 649 me->address = nullptr; … … 696 693 697 694 { 698 std::unique_lock<std::mutex>locker(threadData->parkingLock);695 MutexLocker locker(threadData->parkingLock); 699 696 threadData->address = nullptr; 700 697 threadData->token = 0; 701 698 } 702 threadData->parkingCondition. notify_one();699 threadData->parkingCondition.signal(); 703 700 704 701 return result; … … 742 739 743 740 { 744 std::unique_lock<std::mutex>locker(threadData->parkingLock);741 MutexLocker locker(threadData->parkingLock); 745 742 threadData->address = nullptr; 746 743 } 747 744 // At this point, the threadData may die. Good thing we have a RefPtr<> on it. 748 threadData->parkingCondition. notify_one();745 threadData->parkingCondition.signal(); 749 746 } 750 747 … … 780 777 ASSERT(threadData->address); 781 778 { 782 std::unique_lock<std::mutex>locker(threadData->parkingLock);779 MutexLocker locker(threadData->parkingLock); 783 780 threadData->address = nullptr; 784 781 } 785 threadData->parkingCondition. notify_one();782 threadData->parkingCondition.signal(); 786 783 } 787 784 -
trunk/Source/WTF/wtf/ParkingLot.h
r208209 r208415 27 27 #define WTF_ParkingLot_h 28 28 29 #include <chrono>30 29 #include <functional> 31 30 #include <wtf/Atomics.h> 32 31 #include <wtf/ScopedLambda.h> 33 32 #include <wtf/Threading.h> 33 #include <wtf/TimeWithDynamicClockType.h> 34 34 35 35 namespace WTF { … … 40 40 41 41 public: 42 typedef std::chrono::steady_clock Clock; 42 // ParkingLot will accept any kind of time and convert it internally, but this typedef tells 43 // you what kind of time ParkingLot would be able to use without conversions. It's sad that 44 // this is WallTime not MonotonicTime, but that's just how OS wait functions work. However, 45 // because ParkingLot evaluates whether it should wait by checking if your time has passed 46 // using whatever clock you used, specifying timeouts in MonotonicTime is semantically better. 47 // For example, if the user sets his computer's clock back during the time that you wanted to 48 // wait for one second, and you specified the timeout using the MonotonicTime, then ParkingLot 49 // will be smart enough to know that your one second has elapsed. 50 typedef WallTime Time; 43 51 44 52 // Parks the thread in a queue associated with the given address, which cannot be null. The … … 69 77 const ValidationFunctor& validation, 70 78 const BeforeSleepFunctor& beforeSleep, 71 Clock::time_pointtimeout)79 const TimeWithDynamicClockType& timeout) 72 80 { 73 81 return parkConditionallyImpl( … … 90 98 }, 91 99 [] () { }, 92 Clock::time_point::max());100 Time::infinity()); 93 101 } 94 102 … … 159 167 const ScopedLambda<bool()>& validation, 160 168 const ScopedLambda<void()>& beforeSleep, 161 Clock::time_pointtimeout);169 const TimeWithDynamicClockType& timeout); 162 170 163 171 WTF_EXPORT_PRIVATE static void unparkOneImpl( -
trunk/Source/WTF/wtf/threads/BinarySemaphore.cpp
r188002 r208415 1 1 /* 2 * Copyright (C) 2010 Apple Inc. All rights reserved.2 * Copyright (C) 2010-2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 46 46 } 47 47 48 bool BinarySemaphore::wait( double absoluteTime)48 bool BinarySemaphore::wait(TimeWithDynamicClockType absoluteTime) 49 49 { 50 50 MutexLocker locker(m_mutex); … … 52 52 bool timedOut = false; 53 53 while (!m_isSet) { 54 timedOut = !m_condition.timedWait(m_mutex, absoluteTime); 54 timedOut = !m_condition.timedWait( 55 m_mutex, absoluteTime.approximateWallTime().secondsSinceEpoch().value()); 55 56 if (timedOut) 56 57 return false; -
trunk/Source/WTF/wtf/threads/BinarySemaphore.h
r188002 r208415 1 1 /* 2 * Copyright (C) 2010 , 2011Apple Inc. All rights reserved.2 * Copyright (C) 2010-2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 29 29 #include <wtf/Noncopyable.h> 30 30 #include <wtf/ThreadingPrimitives.h> 31 #include <wtf/TimeWithDynamicClockType.h> 31 32 32 33 namespace WTF { … … 40 41 41 42 WTF_EXPORT_PRIVATE void signal(); 42 WTF_EXPORT_PRIVATE bool wait( double absoluteTime);43 WTF_EXPORT_PRIVATE bool wait(TimeWithDynamicClockType); 43 44 44 45 private: -
trunk/Source/WebCore/ChangeLog
r208414 r208415 1 2016-11-04 Filip Pizlo <fpizlo@apple.com> 2 3 WTF::ParkingLot should stop using std::chrono because std::chrono::duration casts are prone to overflows 4 https://bugs.webkit.org/show_bug.cgi?id=152045 5 6 Reviewed by Andy Estes. 7 8 No new layout tests because no new behavior. The new WTF time classes have some unit tests 9 in TestWebKitAPI. 10 11 * fileapi/ThreadableBlobRegistry.cpp: 12 (WebCore::ThreadableBlobRegistry::blobSize): 13 * platform/MainThreadSharedTimer.h: 14 * platform/SharedTimer.h: 15 * platform/ThreadTimers.cpp: 16 (WebCore::ThreadTimers::updateSharedTimer): 17 * platform/cf/MainThreadSharedTimerCF.cpp: 18 (WebCore::MainThreadSharedTimer::setFireInterval): 19 * platform/efl/MainThreadSharedTimerEfl.cpp: 20 (WebCore::MainThreadSharedTimer::setFireInterval): 21 * platform/glib/MainThreadSharedTimerGLib.cpp: 22 (WebCore::MainThreadSharedTimer::setFireInterval): 23 * platform/win/MainThreadSharedTimerWin.cpp: 24 (WebCore::MainThreadSharedTimer::setFireInterval): 25 * workers/WorkerRunLoop.cpp: 26 (WebCore::WorkerRunLoop::runInMode): 27 1 28 2016-11-04 Zalan Bujtas <zalan@apple.com> 2 29 -
trunk/Source/WebCore/fileapi/ThreadableBlobRegistry.cpp
r204466 r208415 151 151 semaphore.signal(); 152 152 }); 153 semaphore.wait( std::numeric_limits<double>::max());153 semaphore.wait(WallTime::infinity()); 154 154 } 155 155 return resultSize; -
trunk/Source/WebCore/platform/MainThreadSharedTimer.h
r202611 r208415 1 1 /* 2 2 * Copyright (C) 2015 Igalia S.L. 3 * Copyright (C) 2006 Apple Inc. All rights reserved.3 * Copyright (C) 2006-2016 Apple Inc. All rights reserved. 4 4 * 5 5 * Redistribution and use in source and binary forms, with or without … … 43 43 44 44 void setFiredFunction(std::function<void()>&&) override; 45 void setFireInterval( double) override;45 void setFireInterval(Seconds) override; 46 46 void stop() override; 47 47 void invalidate() override; -
trunk/Source/WebCore/platform/SharedTimer.h
r191789 r208415 1 1 /* 2 * Copyright (C) 2006 Apple Inc. All rights reserved.2 * Copyright (C) 2006-2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 30 30 #include <wtf/FastMalloc.h> 31 31 #include <wtf/Noncopyable.h> 32 #include <wtf/Seconds.h> 32 33 33 34 namespace WebCore { … … 44 45 45 46 // The fire interval is in seconds relative to the current monotonic clock time. 46 virtual void setFireInterval( double) = 0;47 virtual void setFireInterval(Seconds) = 0; 47 48 virtual void stop() = 0; 48 49 -
trunk/Source/WebCore/platform/ThreadTimers.cpp
r191789 r208415 1 1 /* 2 * Copyright (C) 2006 , 2008Apple Inc. All rights reserved.2 * Copyright (C) 2006-2016 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2009 Google Inc. All rights reserved. 4 4 * … … 93 93 } 94 94 m_pendingSharedTimerFireTime = nextFireTime; 95 m_sharedTimer->setFireInterval( std::max(nextFireTime - currentMonotonicTime, 0.0));95 m_sharedTimer->setFireInterval(Seconds(std::max(nextFireTime - currentMonotonicTime, 0.0))); 96 96 } 97 97 } -
trunk/Source/WebCore/platform/cf/MainThreadSharedTimerCF.cpp
r191789 r208415 1 1 /* 2 * Copyright (C) 2006 , 2010, 2015Apple Inc. All rights reserved.2 * Copyright (C) 2006-2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 94 94 } 95 95 96 void MainThreadSharedTimer::setFireInterval( doubleinterval)96 void MainThreadSharedTimer::setFireInterval(Seconds interval) 97 97 { 98 98 ASSERT(m_firedFunction); 99 99 100 CFAbsoluteTime fireDate = CFAbsoluteTimeGetCurrent() + interval ;100 CFAbsoluteTime fireDate = CFAbsoluteTimeGetCurrent() + interval.value(); 101 101 if (!sharedTimer) { 102 102 sharedTimer = CFRunLoopTimerCreate(nullptr, fireDate, kCFTimeIntervalDistantFuture, 0, 0, timerFired, nullptr); -
trunk/Source/WebCore/platform/efl/MainThreadSharedTimerEfl.cpp
r191789 r208415 4 4 * (C) 2009-2010 ProFUSION embedded systems 5 5 * (C) 2009-2010 Samsung Electronics 6 * Copyright (C) 2016 Apple Inc. All rights reserved. 6 7 * 7 8 * Redistribution and use in source and binary forms, with or without … … 54 55 } 55 56 56 void MainThreadSharedTimer::setFireInterval( doubleinterval)57 void MainThreadSharedTimer::setFireInterval(Seconds interval) 57 58 { 58 59 stop(); 59 sharedTimer = ecore_timer_loop_add(interval , timerEvent, nullptr);60 sharedTimer = ecore_timer_loop_add(interval.value(), timerEvent, nullptr); 60 61 } 61 62 -
trunk/Source/WebCore/platform/glib/MainThreadSharedTimerGLib.cpp
r202611 r208415 1 1 /* 2 * Copyright (C) 2006 Apple Inc. All rights reserved.2 * Copyright (C) 2006-2016 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com 4 4 * All rights reserved. … … 40 40 } 41 41 42 void MainThreadSharedTimer::setFireInterval( doubleinterval)42 void MainThreadSharedTimer::setFireInterval(Seconds interval) 43 43 { 44 44 ASSERT(m_firedFunction); 45 m_timer.startOneShot(interval );45 m_timer.startOneShot(interval.value()); 46 46 } 47 47 -
trunk/Source/WebCore/platform/win/MainThreadSharedTimerWin.cpp
r191789 r208415 1 1 /* 2 * Copyright (C) 2006 Apple Inc. All rights reserved.2 * Copyright (C) 2006-2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 122 122 } 123 123 124 void MainThreadSharedTimer::setFireInterval( double interval)124 void MainThreadSharedTimer::setFireInterval(Seconds intervalInSeconds) 125 125 { 126 126 ASSERT(m_firedFunction); 127 127 128 double interval = intervalInSeconds.milliseconds(); 128 129 unsigned intervalInMS; 129 interval *= 1000;130 130 if (interval > USER_TIMER_MAXIMUM) 131 131 intervalInMS = USER_TIMER_MAXIMUM; -
trunk/Source/WebCore/workers/WorkerRunLoop.cpp
r208306 r208415 1 1 /* 2 2 * Copyright (C) 2009 Google Inc. All rights reserved. 3 * Copyright (C) 2016 Apple Inc. All rights reserved. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 50 51 // SharedTimer interface. 51 52 void setFiredFunction(std::function<void()>&& function) override { m_sharedTimerFunction = WTFMove(function); } 52 void setFireInterval( double interval) override { m_nextFireTime = interval + currentTime(); }53 void stop() override { m_nextFireTime = 0; }53 void setFireInterval(Seconds interval) override { m_nextFireTime = interval + WallTime::now(); } 54 void stop() override { m_nextFireTime = WallTime(); } 54 55 55 56 bool isActive() { return m_sharedTimerFunction && m_nextFireTime; } 56 double fireTime() { return m_nextFireTime; }57 WallTime fireTime() { return m_nextFireTime; } 57 58 void fire() { m_sharedTimerFunction(); } 58 59 59 60 private: 60 61 std::function<void()> m_sharedTimerFunction; 61 double m_nextFireTime { 0 };62 WallTime m_nextFireTime; 62 63 }; 63 64 … … 158 159 #endif 159 160 160 double deadline = MessageQueue<Task>::infiniteTime();161 WallTime deadline = WallTime::infinity(); 161 162 162 163 #if USE(CF) 163 164 CFAbsoluteTime nextCFRunLoopTimerFireDate = CFRunLoopGetNextTimerFireDate(CFRunLoopGetCurrent(), kCFRunLoopDefaultMode); 164 165 double timeUntilNextCFRunLoopTimerInSeconds = nextCFRunLoopTimerFireDate - CFAbsoluteTimeGetCurrent(); 165 deadline = currentTime() + std::max(0.0, timeUntilNextCFRunLoopTimerInSeconds); 166 #endif 167 168 double absoluteTime = 0.0; 166 deadline = WallTime::now() + std::max( 167 Seconds(0), Seconds(timeUntilNextCFRunLoopTimerInSeconds)); 168 #endif 169 170 WallTime absoluteTime; 169 171 if (waitMode == WaitForMessage) { 170 172 if (predicate.isDefaultMode() && m_sharedTimer->isActive()) -
trunk/Source/WebKit2/ChangeLog
r208406 r208415 1 2016-11-04 Filip Pizlo <fpizlo@apple.com> 2 3 WTF::ParkingLot should stop using std::chrono because std::chrono::duration casts are prone to overflows 4 https://bugs.webkit.org/show_bug.cgi?id=152045 5 6 Reviewed by Andy Estes. 7 8 * Platform/IPC/Connection.cpp: 9 (IPC::Connection::SyncMessageState::wait): 10 (IPC::Connection::sendMessage): 11 (IPC::Connection::timeoutRespectingIgnoreTimeoutsForTesting): 12 (IPC::Connection::waitForMessage): 13 (IPC::Connection::sendSyncMessage): 14 (IPC::Connection::waitForSyncReply): 15 * Platform/IPC/Connection.h: 16 (IPC::Connection::sendSync): 17 (IPC::Connection::waitForAndDispatchImmediately): 18 * Platform/IPC/MessageSender.h: 19 (IPC::MessageSender::sendSync): 20 * UIProcess/ChildProcessProxy.h: 21 (WebKit::ChildProcessProxy::sendSync): 22 * UIProcess/Network/NetworkProcessProxy.cpp: 23 (WebKit::NetworkProcessProxy::sendProcessWillSuspendImminently): 24 * UIProcess/Storage/StorageManager.cpp: 25 (WebKit::StorageManager::applicationWillTerminate): 26 * UIProcess/WebProcessProxy.cpp: 27 (WebKit::WebProcessProxy::sendProcessWillSuspendImminently): 28 * UIProcess/WebResourceLoadStatisticsStore.cpp: 29 (WebKit::WebResourceLoadStatisticsStore::applicationWillTerminate): 30 * UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.h: 31 * UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm: 32 (-[WKOneShotDisplayLinkHandler displayLinkFired:]): 33 (WebKit::RemoteLayerTreeDrawingAreaProxy::commitLayerTree): 34 (WebKit::RemoteLayerTreeDrawingAreaProxy::didRefreshDisplay): 35 (WebKit::RemoteLayerTreeDrawingAreaProxy::waitForDidUpdateActivityState): 36 * UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm: 37 (WebKit::TiledCoreAnimationDrawingAreaProxy::waitForDidUpdateActivityState): 38 * UIProcess/mac/WKImmediateActionController.mm: 39 (-[WKImmediateActionController immediateActionRecognizerWillBeginAnimation:]): 40 * UIProcess/mac/WebPageProxyMac.mm: 41 (WebKit::WebPageProxy::stringSelectionForPasteboard): 42 (WebKit::WebPageProxy::dataSelectionForPasteboard): 43 (WebKit::WebPageProxy::readSelectionFromPasteboard): 44 (WebKit::WebPageProxy::shouldDelayWindowOrderingForEvent): 45 (WebKit::WebPageProxy::acceptsFirstMouse): 46 * WebProcess/WebCoreSupport/WebChromeClient.cpp: 47 (WebKit::WebChromeClient::runBeforeUnloadConfirmPanel): 48 (WebKit::WebChromeClient::runJavaScriptAlert): 49 (WebKit::WebChromeClient::runJavaScriptConfirm): 50 (WebKit::WebChromeClient::runJavaScriptPrompt): 51 (WebKit::WebChromeClient::print): 52 (WebKit::WebChromeClient::exceededDatabaseQuota): 53 (WebKit::WebChromeClient::reachedApplicationCacheOriginQuota): 54 * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp: 55 (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForResponse): 56 * WebProcess/WebPage/WebPage.cpp: 57 (WebKit::WebPage::postSynchronousMessageForTesting): 58 1 59 2016-11-04 Wenson Hsieh <wenson_hsieh@apple.com> 2 60 -
trunk/Source/WebKit2/Platform/IPC/Connection.cpp
r205275 r208415 1 1 /* 2 * Copyright (C) 2010 Apple Inc. All rights reserved.2 * Copyright (C) 2010-2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 74 74 } 75 75 76 bool wait( double absoluteTime)76 bool wait(TimeWithDynamicClockType absoluteTime) 77 77 { 78 78 return m_waitForSyncReplySemaphore.wait(absoluteTime); … … 377 377 wrappedMessage->setFullySynchronousModeForTesting(); 378 378 wrappedMessage->wrapForTesting(WTFMove(encoder)); 379 return static_cast<bool>(sendSyncMessage(syncRequestID, WTFMove(wrappedMessage), std::chrono::milliseconds::max(), { }));379 return static_cast<bool>(sendSyncMessage(syncRequestID, WTFMove(wrappedMessage), Seconds::infinity(), { })); 380 380 } 381 381 … … 421 421 } 422 422 423 std::chrono::milliseconds Connection::timeoutRespectingIgnoreTimeoutsForTesting(std::chrono::milliseconds timeout) const424 { 425 return m_ignoreTimeoutsForTesting ? std::chrono::milliseconds::max() : timeout;426 } 427 428 std::unique_ptr<Decoder> Connection::waitForMessage(StringReference messageReceiverName, StringReference messageName, uint64_t destinationID, std::chrono::milliseconds timeout, OptionSet<WaitForOption> waitForOptions)423 Seconds Connection::timeoutRespectingIgnoreTimeoutsForTesting(Seconds timeout) const 424 { 425 return m_ignoreTimeoutsForTesting ? Seconds::infinity() : timeout; 426 } 427 428 std::unique_ptr<Decoder> Connection::waitForMessage(StringReference messageReceiverName, StringReference messageName, uint64_t destinationID, Seconds timeout, OptionSet<WaitForOption> waitForOptions) 429 429 { 430 430 ASSERT(RunLoop::isMain()); … … 470 470 } 471 471 472 // Clamp the timeout to however much time is remaining on our clock. 473 auto now = Condition::Clock::now(); 474 auto remainingClockTime = std::chrono::duration_cast<std::chrono::milliseconds>(Condition::Clock::time_point::max() - now); 475 auto absoluteTimeout = now + std::min(remainingClockTime, timeout); 472 MonotonicTime absoluteTimeout = MonotonicTime::now() + timeout; 476 473 477 474 // Now wait for it to be set. … … 497 494 } 498 495 499 std::unique_ptr<Decoder> Connection::sendSyncMessage(uint64_t syncRequestID, std::unique_ptr<Encoder> encoder, std::chrono::milliseconds timeout, OptionSet<SendSyncOption> sendSyncOptions)496 std::unique_ptr<Decoder> Connection::sendSyncMessage(uint64_t syncRequestID, std::unique_ptr<Encoder> encoder, Seconds timeout, OptionSet<SendSyncOption> sendSyncOptions) 500 497 { 501 498 ASSERT(RunLoop::isMain()); … … 542 539 } 543 540 544 std::unique_ptr<Decoder> Connection::waitForSyncReply(uint64_t syncRequestID, std::chrono::milliseconds timeout, OptionSet<SendSyncOption> sendSyncOptions)541 std::unique_ptr<Decoder> Connection::waitForSyncReply(uint64_t syncRequestID, Seconds timeout, OptionSet<SendSyncOption> sendSyncOptions) 545 542 { 546 543 timeout = timeoutRespectingIgnoreTimeoutsForTesting(timeout); 547 double absoluteTime = currentTime() + (timeout.count() / 1000.0);544 WallTime absoluteTime = WallTime::now() + timeout; 548 545 549 546 willSendSyncMessage(sendSyncOptions); -
trunk/Source/WebKit2/Platform/IPC/Connection.h
r205207 r208415 1 1 /* 2 * Copyright (C) 2010 Apple Inc. All rights reserved.2 * Copyright (C) 2010-2016 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 4 4 * Portions Copyright (c) 2010 Motorola Mobility, Inc. All rights reserved. … … 167 167 template<typename T> bool send(T&& message, uint64_t destinationID, OptionSet<SendOption> sendOptions = { }); 168 168 template<typename T> void sendWithReply(T&& message, uint64_t destinationID, FunctionDispatcher& replyDispatcher, Function<void (Optional<typename CodingType<typename T::Reply>::Type>)>&& replyHandler); 169 template<typename T> bool sendSync(T&& message, typename T::Reply&& reply, uint64_t destinationID, std::chrono::milliseconds timeout = std::chrono::milliseconds::max(), OptionSet<SendSyncOption> sendSyncOptions = { });170 template<typename T> bool waitForAndDispatchImmediately(uint64_t destinationID, std::chrono::milliseconds timeout, OptionSet<WaitForOption> waitForOptions = { });169 template<typename T> bool sendSync(T&& message, typename T::Reply&& reply, uint64_t destinationID, Seconds timeout = Seconds::infinity(), OptionSet<SendSyncOption> sendSyncOptions = { }); 170 template<typename T> bool waitForAndDispatchImmediately(uint64_t destinationID, Seconds timeout, OptionSet<WaitForOption> waitForOptions = { }); 171 171 172 172 bool sendMessage(std::unique_ptr<Encoder>, OptionSet<SendOption> sendOptions); 173 173 void sendMessageWithReply(uint64_t requestID, std::unique_ptr<Encoder>, FunctionDispatcher& replyDispatcher, Function<void (std::unique_ptr<Decoder>)>&& replyHandler); 174 174 std::unique_ptr<Encoder> createSyncMessageEncoder(StringReference messageReceiverName, StringReference messageName, uint64_t destinationID, uint64_t& syncRequestID); 175 std::unique_ptr<Decoder> sendSyncMessage(uint64_t syncRequestID, std::unique_ptr<Encoder>, std::chrono::milliseconds timeout, OptionSet<SendSyncOption> sendSyncOptions);175 std::unique_ptr<Decoder> sendSyncMessage(uint64_t syncRequestID, std::unique_ptr<Encoder>, Seconds timeout, OptionSet<SendSyncOption> sendSyncOptions); 176 176 bool sendSyncReply(std::unique_ptr<Encoder>); 177 177 … … 209 209 void platformInvalidate(); 210 210 211 std::unique_ptr<Decoder> waitForMessage(StringReference messageReceiverName, StringReference messageName, uint64_t destinationID, std::chrono::milliseconds timeout, OptionSet<WaitForOption>);212 213 std::unique_ptr<Decoder> waitForSyncReply(uint64_t syncRequestID, std::chrono::milliseconds timeout, OptionSet<SendSyncOption>);211 std::unique_ptr<Decoder> waitForMessage(StringReference messageReceiverName, StringReference messageName, uint64_t destinationID, Seconds timeout, OptionSet<WaitForOption>); 212 213 std::unique_ptr<Decoder> waitForSyncReply(uint64_t syncRequestID, Seconds timeout, OptionSet<SendSyncOption>); 214 214 215 215 // Called on the connection work queue. … … 239 239 void didReceiveSyncReply(OptionSet<SendSyncOption>); 240 240 241 std::chrono::milliseconds timeoutRespectingIgnoreTimeoutsForTesting(std::chrono::milliseconds) const;241 Seconds timeoutRespectingIgnoreTimeoutsForTesting(Seconds) const; 242 242 243 243 Client& m_client; … … 366 366 } 367 367 368 template<typename T> bool Connection::sendSync(T&& message, typename T::Reply&& reply, uint64_t destinationID, std::chrono::milliseconds timeout, OptionSet<SendSyncOption> sendSyncOptions)368 template<typename T> bool Connection::sendSync(T&& message, typename T::Reply&& reply, uint64_t destinationID, Seconds timeout, OptionSet<SendSyncOption> sendSyncOptions) 369 369 { 370 370 COMPILE_ASSERT(T::isSync, SyncMessageExpected); … … 390 390 } 391 391 392 template<typename T> bool Connection::waitForAndDispatchImmediately(uint64_t destinationID, std::chrono::milliseconds timeout, OptionSet<WaitForOption> waitForOptions)392 template<typename T> bool Connection::waitForAndDispatchImmediately(uint64_t destinationID, Seconds timeout, OptionSet<WaitForOption> waitForOptions) 393 393 { 394 394 std::unique_ptr<Decoder> decoder = waitForMessage(T::receiverName(), T::name(), destinationID, timeout, waitForOptions); -
trunk/Source/WebKit2/Platform/IPC/MessageSender.h
r204996 r208415 1 1 /* 2 * Copyright (C) 2010 Apple Inc. All rights reserved.2 * Copyright (C) 2010-2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 51 51 52 52 template<typename T> 53 bool sendSync(T&& message, typename T::Reply&& reply, std::chrono::milliseconds timeout = std::chrono::milliseconds::max(), OptionSet<SendSyncOption> sendSyncOptions = { })53 bool sendSync(T&& message, typename T::Reply&& reply, Seconds timeout = Seconds::infinity(), OptionSet<SendSyncOption> sendSyncOptions = { }) 54 54 { 55 55 static_assert(T::isSync, "Message is not sync!"); … … 59 59 60 60 template<typename T> 61 bool sendSync(T&& message, typename T::Reply&& reply, uint64_t destinationID, std::chrono::milliseconds timeout = std::chrono::milliseconds::max(), OptionSet<SendSyncOption> sendSyncOptions = { })61 bool sendSync(T&& message, typename T::Reply&& reply, uint64_t destinationID, Seconds timeout = Seconds::infinity(), OptionSet<SendSyncOption> sendSyncOptions = { }) 62 62 { 63 63 ASSERT(messageSenderConnection()); -
trunk/Source/WebKit2/UIProcess/AcceleratedDrawingAreaProxy.cpp
r207658 r208415 237 237 238 238 // The timeout, in seconds, we use when waiting for a DidUpdateBackingStoreState message when we're asked to paint. 239 m_webPageProxy.process().connection()->waitForAndDispatchImmediately<Messages::DrawingAreaProxy::DidUpdateBackingStoreState>(m_webPageProxy.pageID(), std::chrono::milliseconds(500));239 m_webPageProxy.process().connection()->waitForAndDispatchImmediately<Messages::DrawingAreaProxy::DidUpdateBackingStoreState>(m_webPageProxy.pageID(), Seconds::fromMilliseconds(500)); 240 240 } 241 241 -
trunk/Source/WebKit2/UIProcess/ChildProcessProxy.h
r205159 r208415 1 1 /* 2 * Copyright (C) 2012 Apple Inc. All rights reserved.2 * Copyright (C) 2012-2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 45 45 46 46 template<typename T> bool send(T&& message, uint64_t destinationID, OptionSet<IPC::SendOption> sendOptions = { }); 47 template<typename T> bool sendSync(T&& message, typename T::Reply&&, uint64_t destinationID, std::chrono::milliseconds timeout = std::chrono::seconds(1), OptionSet<IPC::SendSyncOption> sendSyncOptions = { });47 template<typename T> bool sendSync(T&& message, typename T::Reply&&, uint64_t destinationID, Seconds timeout = Seconds(1), OptionSet<IPC::SendSyncOption> sendSyncOptions = { }); 48 48 49 49 IPC::Connection* connection() const … … 103 103 104 104 template<typename U> 105 bool ChildProcessProxy::sendSync(U&& message, typename U::Reply&& reply, uint64_t destinationID, std::chrono::milliseconds timeout, OptionSet<IPC::SendSyncOption> sendSyncOptions)105 bool ChildProcessProxy::sendSync(U&& message, typename U::Reply&& reply, uint64_t destinationID, Seconds timeout, OptionSet<IPC::SendSyncOption> sendSyncOptions) 106 106 { 107 107 COMPILE_ASSERT(U::isSync, SyncMessageExpected); -
trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.h
r208225 r208415 72 72 73 73 // The timeout we use when waiting for a DidUpdateGeometry message. 74 static constexpr std::chrono::milliseconds didUpdateBackingStoreStateTimeout() { return std::chrono::milliseconds(500); }74 static constexpr Seconds didUpdateBackingStoreStateTimeout() { return Seconds::fromMilliseconds(500); } 75 75 76 virtual void waitForPossibleGeometryUpdate( std::chrono::milliseconds = didUpdateBackingStoreStateTimeout()) { }76 virtual void waitForPossibleGeometryUpdate(Seconds = didUpdateBackingStoreStateTimeout()) { } 77 77 78 78 virtual void colorSpaceDidChange() { } -
trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp
r207346 r208415 1 1 /* 2 * Copyright (C) 2012 Apple Inc. All rights reserved.2 * Copyright (C) 2012-2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 370 370 371 371 bool handled = false; 372 sendSync(Messages::NetworkProcess::ProcessWillSuspendImminently(), Messages::NetworkProcess::ProcessWillSuspendImminently::Reply(handled), 0, std::chrono::seconds(1));372 sendSync(Messages::NetworkProcess::ProcessWillSuspendImminently(), Messages::NetworkProcess::ProcessWillSuspendImminently::Reply(handled), 0, Seconds(1)); 373 373 } 374 374 -
trunk/Source/WebKit2/UIProcess/Storage/StorageManager.cpp
r203303 r208415 1 1 /* 2 * Copyright (C) 2013 Apple Inc. All rights reserved.2 * Copyright (C) 2013-2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 844 844 semaphore.signal(); 845 845 }); 846 semaphore.wait( std::numeric_limits<double>::max());846 semaphore.wait(WallTime::infinity()); 847 847 } 848 848 -
trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp
r208225 r208415 907 907 908 908 bool handled = false; 909 sendSync(Messages::WebProcess::ProcessWillSuspendImminently(), Messages::WebProcess::ProcessWillSuspendImminently::Reply(handled), 0, std::chrono::seconds(1));909 sendSync(Messages::WebProcess::ProcessWillSuspendImminently(), Messages::WebProcess::ProcessWillSuspendImminently::Reply(handled), 0, Seconds(1)); 910 910 } 911 911 -
trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.cpp
r206869 r208415 214 214 semaphore.signal(); 215 215 }); 216 semaphore.wait( std::numeric_limits<double>::max());216 semaphore.wait(WallTime::infinity()); 217 217 } 218 218 -
trunk/Source/WebKit2/UIProcess/ios/WKContentView.mm
r208371 r208415 679 679 { 680 680 if (_isPrintingToPDF) { 681 if (!_page->process().connection()->waitForAndDispatchImmediately<Messages::WebPageProxy::DrawToPDFCallback>(_page->pageID(), std::chrono::milliseconds::max())) {681 if (!_page->process().connection()->waitForAndDispatchImmediately<Messages::WebPageProxy::DrawToPDFCallback>(_page->pageID(), Seconds::infinity())) { 682 682 ASSERT_NOT_REACHED(); 683 683 return nullptr; -
trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm
r208361 r208415 296 296 FloatPoint newScrollPosition; 297 297 uint64_t nextValidLayerTreeTransactionID; 298 if (m_process->sendSync(Messages::WebPage::SynchronizeDynamicViewportUpdate(), Messages::WebPage::SynchronizeDynamicViewportUpdate::Reply(newScale, newScrollPosition, nextValidLayerTreeTransactionID), m_pageID, std::chrono::seconds(2))) {298 if (m_process->sendSync(Messages::WebPage::SynchronizeDynamicViewportUpdate(), Messages::WebPage::SynchronizeDynamicViewportUpdate::Reply(newScale, newScrollPosition, nextValidLayerTreeTransactionID), m_pageID, Seconds(2))) { 299 299 m_dynamicViewportSizeUpdateWaitingForTarget = false; 300 300 m_dynamicViewportSizeUpdateLayerTreeTransactionID = nextValidLayerTreeTransactionID; -
trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.h
r208225 r208415 1 1 /* 2 * Copyright (C) 2012-201 4Apple Inc. All rights reserved.2 * Copyright (C) 2012-2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 53 53 uint64_t lastCommittedLayerTreeTransactionID() const { return m_transactionIDForPendingCACommit; } 54 54 55 void didRefreshDisplay( double timestamp);55 void didRefreshDisplay(); 56 56 57 57 private: -
trunk/Source/WebKit2/UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm
r208395 r208415 1 1 /* 2 * Copyright (C) 2012-201 4Apple Inc. All rights reserved.2 * Copyright (C) 2012-2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 82 82 { 83 83 ASSERT(isUIThread()); 84 _drawingAreaProxy->didRefreshDisplay( sender.timestamp);84 _drawingAreaProxy->didRefreshDisplay(); 85 85 } 86 86 … … 229 229 #if PLATFORM(IOS) 230 230 if (std::exchange(m_didUpdateMessageState, NeedsDidUpdate) == MissedCommit) 231 didRefreshDisplay( monotonicallyIncreasingTime());231 didRefreshDisplay(); 232 232 [m_displayLinkHandler schedule]; 233 233 #else 234 234 m_didUpdateMessageState = NeedsDidUpdate; 235 didRefreshDisplay( monotonicallyIncreasingTime());235 didRefreshDisplay(); 236 236 #endif 237 237 … … 395 395 } 396 396 397 void RemoteLayerTreeDrawingAreaProxy::didRefreshDisplay( double)397 void RemoteLayerTreeDrawingAreaProxy::didRefreshDisplay() 398 398 { 399 399 if (!m_webPageProxy.isValid()) … … 427 427 // we can be guaranteed that the next commit won't come until after the waitForAndDispatchImmediately times out. 428 428 if (m_didUpdateMessageState != DoesNotNeedDidUpdate) 429 didRefreshDisplay( monotonicallyIncreasingTime());430 431 static std::chrono::milliseconds activityStateUpdateTimeout = [] {429 didRefreshDisplay(); 430 431 static Seconds activityStateUpdateTimeout = [] { 432 432 if (id value = [[NSUserDefaults standardUserDefaults] objectForKey:@"WebKitOverrideActivityStateUpdateTimeout"]) 433 return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::duration<double>([value doubleValue]));434 435 #if PLATFORM(IOS) 436 return std::chrono::milliseconds(500);433 return Seconds([value doubleValue]); 434 435 #if PLATFORM(IOS) 436 return Seconds::fromMilliseconds(500); 437 437 #else 438 return std::chrono::milliseconds(250);438 return Seconds::fromMilliseconds(250); 439 439 #endif 440 440 }(); -
trunk/Source/WebKit2/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h
r208225 r208415 42 42 void deviceScaleFactorDidChange() override; 43 43 void sizeDidChange() override; 44 void waitForPossibleGeometryUpdate( std::chrono::milliseconds timeout = didUpdateBackingStoreStateTimeout()) override;44 void waitForPossibleGeometryUpdate(Seconds timeout = didUpdateBackingStoreStateTimeout()) override; 45 45 void colorSpaceDidChange() override; 46 46 void minimumLayoutSizeDidChange() override; -
trunk/Source/WebKit2/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm
r208225 r208415 1 1 /* 2 * Copyright (C) 2011 Apple Inc. All rights reserved.2 * Copyright (C) 2011-2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 71 71 } 72 72 73 void TiledCoreAnimationDrawingAreaProxy::waitForPossibleGeometryUpdate( std::chrono::milliseconds timeout)73 void TiledCoreAnimationDrawingAreaProxy::waitForPossibleGeometryUpdate(Seconds timeout) 74 74 { 75 75 #if !HAVE(COREANIMATION_FENCES) … … 134 134 void TiledCoreAnimationDrawingAreaProxy::waitForDidUpdateActivityState() 135 135 { 136 auto activityStateUpdateTimeout = std::chrono::milliseconds(250);136 Seconds activityStateUpdateTimeout = Seconds::fromMilliseconds(250); 137 137 m_webPageProxy.process().connection()->waitForAndDispatchImmediately<Messages::WebPageProxy::DidUpdateActivityState>(m_webPageProxy.pageID(), activityStateUpdateTimeout, IPC::WaitForOption::InterruptWaitingIfSyncMessageArrives); 138 138 } -
trunk/Source/WebKit2/UIProcess/mac/WKImmediateActionController.mm
r208342 r208415 1 1 /* 2 * Copyright (C) 2014 Apple Inc. All rights reserved.2 * Copyright (C) 2014-2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 197 197 if (_state == ImmediateActionState::Pending) { 198 198 if (auto* connection = _page->process().connection()) { 199 bool receivedReply = connection->waitForAndDispatchImmediately<Messages::WebPageProxy::DidPerformImmediateActionHitTest>(_page->pageID(), std::chrono::milliseconds(500));199 bool receivedReply = connection->waitForAndDispatchImmediately<Messages::WebPageProxy::DidPerformImmediateActionHitTest>(_page->pageID(), Seconds::fromMilliseconds(500)); 200 200 if (!receivedReply) 201 201 _state = ImmediateActionState::TimedOut; -
trunk/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm
r208361 r208415 1 1 /* 2 * Copyright (C) 2010 , 2011, 2015Apple Inc. All rights reserved.2 * Copyright (C) 2010-2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 231 231 return value; 232 232 233 const auto messageTimeout = std::chrono::seconds(20);233 const Seconds messageTimeout(20); 234 234 process().sendSync(Messages::WebPage::GetStringSelectionForPasteboard(), Messages::WebPage::GetStringSelectionForPasteboard::Reply(value), m_pageID, messageTimeout); 235 235 return value; … … 242 242 SharedMemory::Handle handle; 243 243 uint64_t size = 0; 244 const auto messageTimeout = std::chrono::seconds(20);244 const Seconds messageTimeout(20); 245 245 process().sendSync(Messages::WebPage::GetDataSelectionForPasteboard(pasteboardType), 246 246 Messages::WebPage::GetDataSelectionForPasteboard::Reply(handle, size), m_pageID, messageTimeout); … … 257 257 258 258 bool result = false; 259 const auto messageTimeout = std::chrono::seconds(20);259 const Seconds messageTimeout(20); 260 260 process().sendSync(Messages::WebPage::ReadSelectionFromPasteboard(pasteboardName), Messages::WebPage::ReadSelectionFromPasteboard::Reply(result), m_pageID, messageTimeout); 261 261 return result; … … 410 410 411 411 bool result = false; 412 const auto messageTimeout = std::chrono::seconds(3);412 const Seconds messageTimeout(3); 413 413 process().sendSync(Messages::WebPage::ShouldDelayWindowOrderingEvent(event), Messages::WebPage::ShouldDelayWindowOrderingEvent::Reply(result), m_pageID, messageTimeout); 414 414 return result; … … 421 421 422 422 bool result = false; 423 const auto messageTimeout = std::chrono::seconds(3);423 const Seconds messageTimeout(3); 424 424 process().sendSync(Messages::WebPage::AcceptsFirstMouse(eventNumber, event), Messages::WebPage::AcceptsFirstMouse::Reply(result), m_pageID, messageTimeout); 425 425 return result; -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
r207706 r208415 355 355 HangDetectionDisabler hangDetectionDisabler; 356 356 357 if (!WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPageProxy::RunBeforeUnloadConfirmPanel(message, webFrame->frameID()), Messages::WebPageProxy::RunBeforeUnloadConfirmPanel::Reply(shouldClose), m_page->pageID(), std::chrono::milliseconds::max(), IPC::SendSyncOption::InformPlatformProcessWillSuspend))357 if (!WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPageProxy::RunBeforeUnloadConfirmPanel(message, webFrame->frameID()), Messages::WebPageProxy::RunBeforeUnloadConfirmPanel::Reply(shouldClose), m_page->pageID(), Seconds::infinity(), IPC::SendSyncOption::InformPlatformProcessWillSuspend)) 358 358 return false; 359 359 … … 401 401 HangDetectionDisabler hangDetectionDisabler; 402 402 403 WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPageProxy::RunJavaScriptAlert(webFrame->frameID(), SecurityOriginData::fromFrame(frame), alertText), Messages::WebPageProxy::RunJavaScriptAlert::Reply(), m_page->pageID(), std::chrono::milliseconds::max(), IPC::SendSyncOption::InformPlatformProcessWillSuspend);403 WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPageProxy::RunJavaScriptAlert(webFrame->frameID(), SecurityOriginData::fromFrame(frame), alertText), Messages::WebPageProxy::RunJavaScriptAlert::Reply(), m_page->pageID(), Seconds::infinity(), IPC::SendSyncOption::InformPlatformProcessWillSuspend); 404 404 } 405 405 … … 418 418 419 419 bool result = false; 420 if (!WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPageProxy::RunJavaScriptConfirm(webFrame->frameID(), SecurityOriginData::fromFrame(frame), message), Messages::WebPageProxy::RunJavaScriptConfirm::Reply(result), m_page->pageID(), std::chrono::milliseconds::max(), IPC::SendSyncOption::InformPlatformProcessWillSuspend))420 if (!WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPageProxy::RunJavaScriptConfirm(webFrame->frameID(), SecurityOriginData::fromFrame(frame), message), Messages::WebPageProxy::RunJavaScriptConfirm::Reply(result), m_page->pageID(), Seconds::infinity(), IPC::SendSyncOption::InformPlatformProcessWillSuspend)) 421 421 return false; 422 422 … … 437 437 HangDetectionDisabler hangDetectionDisabler; 438 438 439 if (!WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPageProxy::RunJavaScriptPrompt(webFrame->frameID(), SecurityOriginData::fromFrame(frame), message, defaultValue), Messages::WebPageProxy::RunJavaScriptPrompt::Reply(result), m_page->pageID(), std::chrono::milliseconds::max(), IPC::SendSyncOption::InformPlatformProcessWillSuspend))439 if (!WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPageProxy::RunJavaScriptPrompt(webFrame->frameID(), SecurityOriginData::fromFrame(frame), message, defaultValue), Messages::WebPageProxy::RunJavaScriptPrompt::Reply(result), m_page->pageID(), Seconds::infinity(), IPC::SendSyncOption::InformPlatformProcessWillSuspend)) 440 440 return false; 441 441 … … 669 669 #endif 670 670 671 m_page->sendSync(Messages::WebPageProxy::PrintFrame(webFrame->frameID()), Messages::WebPageProxy::PrintFrame::Reply(), std::chrono::milliseconds::max(), IPC::SendSyncOption::InformPlatformProcessWillSuspend);671 m_page->sendSync(Messages::WebPageProxy::PrintFrame(webFrame->frameID()), Messages::WebPageProxy::PrintFrame::Reply(), Seconds::infinity(), IPC::SendSyncOption::InformPlatformProcessWillSuspend); 672 672 } 673 673 … … 689 689 WebProcess::singleton().parentProcessConnection()->sendSync( 690 690 Messages::WebPageProxy::ExceededDatabaseQuota(webFrame->frameID(), origin->databaseIdentifier(), databaseName, details.displayName(), currentQuota, currentOriginUsage, details.currentUsage(), details.expectedUsage()), 691 Messages::WebPageProxy::ExceededDatabaseQuota::Reply(newQuota), m_page->pageID(), std::chrono::milliseconds::max(), IPC::SendSyncOption::InformPlatformProcessWillSuspend);691 Messages::WebPageProxy::ExceededDatabaseQuota::Reply(newQuota), m_page->pageID(), Seconds::infinity(), IPC::SendSyncOption::InformPlatformProcessWillSuspend); 692 692 } 693 693 … … 714 714 WebProcess::singleton().parentProcessConnection()->sendSync( 715 715 Messages::WebPageProxy::ReachedApplicationCacheOriginQuota(origin->databaseIdentifier(), currentQuota, totalBytesNeeded), 716 Messages::WebPageProxy::ReachedApplicationCacheOriginQuota::Reply(newQuota), m_page->pageID(), std::chrono::milliseconds::max(), IPC::SendSyncOption::InformPlatformProcessWillSuspend);716 Messages::WebPageProxy::ReachedApplicationCacheOriginQuota::Reply(newQuota), m_page->pageID(), Seconds::infinity(), IPC::SendSyncOption::InformPlatformProcessWillSuspend); 717 717 718 718 cacheStorage.storeUpdatedQuotaForOrigin(origin, newQuota); -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
r207484 r208415 691 691 Ref<WebFrame> protect(*m_frame); 692 692 WebCore::Frame* coreFrame = m_frame->coreFrame(); 693 if (!webPage->sendSync(Messages::WebPageProxy::DecidePolicyForResponseSync(m_frame->frameID(), SecurityOriginData::fromFrame(coreFrame), response, request, canShowMIMEType, listenerID, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())), Messages::WebPageProxy::DecidePolicyForResponseSync::Reply(receivedPolicyAction, policyAction, downloadID), std::chrono::milliseconds::max(), IPC::SendSyncOption::InformPlatformProcessWillSuspend)) {693 if (!webPage->sendSync(Messages::WebPageProxy::DecidePolicyForResponseSync(m_frame->frameID(), SecurityOriginData::fromFrame(coreFrame), response, request, canShowMIMEType, listenerID, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())), Messages::WebPageProxy::DecidePolicyForResponseSync::Reply(receivedPolicyAction, policyAction, downloadID), Seconds::infinity(), IPC::SendSyncOption::InformPlatformProcessWillSuspend)) { 694 694 m_frame->didReceivePolicyDecision(listenerID, PolicyIgnore, 0, { }); 695 695 return; -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
r208406 r208415 1 2 1 /* 3 2 * Copyright (C) 2010-2016 Apple Inc. All rights reserved. … … 5549 5548 5550 5549 auto& webProcess = WebProcess::singleton(); 5551 if (!sendSync(Messages::WebPageProxy::HandleSynchronousMessage(messageName, UserData(webProcess.transformObjectsToHandles(messageBody))), Messages::WebPageProxy::HandleSynchronousMessage::Reply(returnUserData), std::chrono::milliseconds::max(), IPC::SendSyncOption::UseFullySynchronousModeForTesting))5550 if (!sendSync(Messages::WebPageProxy::HandleSynchronousMessage(messageName, UserData(webProcess.transformObjectsToHandles(messageBody))), Messages::WebPageProxy::HandleSynchronousMessage::Reply(returnUserData), Seconds::infinity(), IPC::SendSyncOption::UseFullySynchronousModeForTesting)) 5552 5551 returnData = nullptr; 5553 5552 else -
trunk/Tools/ChangeLog
r208400 r208415 1 2016-11-04 Filip Pizlo <fpizlo@apple.com> 2 3 WTF::ParkingLot should stop using std::chrono because std::chrono::duration casts are prone to overflows 4 https://bugs.webkit.org/show_bug.cgi?id=152045 5 6 Reviewed by Andy Estes. 7 8 * TestWebKitAPI/CMakeLists.txt: 9 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 10 * TestWebKitAPI/Tests/WTF/Condition.cpp: 11 (TestWebKitAPI::TEST): 12 * TestWebKitAPI/Tests/WTF/SynchronizedFixedQueue.cpp: 13 (TestWebKitAPI::ToUpperConverter::stopProducing): 14 (TestWebKitAPI::ToUpperConverter::stopConsuming): 15 * TestWebKitAPI/Tests/WTF/Time.cpp: Added. 16 (WTF::operator<<): 17 (TestWebKitAPI::TEST): 18 1 19 2016-11-04 Alex Christensen <achristensen@webkit.org> 2 20 -
trunk/Tools/TestWebKitAPI/CMakeLists.txt
r207325 r208415 79 79 ${TESTWEBKITAPI_DIR}/Tests/WTF/StringView.cpp 80 80 ${TESTWEBKITAPI_DIR}/Tests/WTF/TemporaryChange.cpp 81 ${TESTWEBKITAPI_DIR}/Tests/WTF/Time.cpp 81 82 ${TESTWEBKITAPI_DIR}/Tests/WTF/UniqueRef.cpp 82 83 ${TESTWEBKITAPI_DIR}/Tests/WTF/Variant.cpp -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r208340 r208415 26 26 0F139E781A423A6B00F590F5 /* PlatformUtilitiesCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0F139E721A423A2B00F590F5 /* PlatformUtilitiesCocoa.mm */; }; 27 27 0F139E791A42457000F590F5 /* PlatformUtilitiesCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0F139E721A423A2B00F590F5 /* PlatformUtilitiesCocoa.mm */; }; 28 0F2C20B81DCD545000542D9E /* Time.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F2C20B71DCD544800542D9E /* Time.cpp */; }; 28 29 0F3B94A71A77267400DE3272 /* WKWebViewEvaluateJavaScript.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0F3B94A51A77266C00DE3272 /* WKWebViewEvaluateJavaScript.mm */; }; 29 30 1A02C870125D4CFD00E3F4BD /* find.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 1A02C84B125D4A5E00E3F4BD /* find.html */; }; … … 723 724 0F139E751A423A5300F590F5 /* WeakObjCPtr.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WeakObjCPtr.mm; path = cocoa/WeakObjCPtr.mm; sourceTree = "<group>"; }; 724 725 0F17BBD415AF6C4D007AB753 /* WebCoreStatisticsWithNoWebProcess.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebCoreStatisticsWithNoWebProcess.cpp; sourceTree = "<group>"; }; 726 0F2C20B71DCD544800542D9E /* Time.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Time.cpp; sourceTree = "<group>"; }; 725 727 0F3B94A51A77266C00DE3272 /* WKWebViewEvaluateJavaScript.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewEvaluateJavaScript.mm; sourceTree = "<group>"; }; 726 728 0FC6C4CB141027E0005B7F0C /* RedBlackTree.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RedBlackTree.cpp; sourceTree = "<group>"; }; … … 1826 1828 5597F8341D9596C80066BC21 /* SynchronizedFixedQueue.cpp */, 1827 1829 0BCD85691485C98B00EA2003 /* TemporaryChange.cpp */, 1830 0F2C20B71DCD544800542D9E /* Time.cpp */, 1828 1831 5C5E633D1D0B67940085A025 /* UniqueRef.cpp */, 1829 1832 7CD0D5AA1D5534DE000CC9E1 /* Variant.cpp */, … … 2288 2291 1A77BAA31D9AFFFC005FC568 /* OptionSet.cpp in Sources */, 2289 2292 7C83DEC31D0A590C00FEBCF3 /* Condition.cpp in Sources */, 2293 0F2C20B81DCD545000542D9E /* Time.cpp in Sources */, 2290 2294 1A3524AE1D63A4FB0031729B /* Scope.cpp in Sources */, 2291 2295 7C83DEA61D0A590C00FEBCF3 /* Counters.cpp in Sources */, -
trunk/Tools/TestWebKitAPI/Tests/WTF/Condition.cpp
r188618 r208415 1 1 /* 2 * Copyright (C) 2015 Apple Inc. All rights reserved.2 * Copyright (C) 2015-2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 49 49 50 50 template<typename Functor> 51 void wait(Condition& condition, std::unique_lock<Lock>& locker, const Functor& predicate, std::chrono::microseconds timeout)52 { 53 if (timeout == std::chrono::microseconds::max())51 void wait(Condition& condition, std::unique_lock<Lock>& locker, const Functor& predicate, Seconds timeout) 52 { 53 if (timeout == Seconds::infinity()) 54 54 condition.wait(locker, predicate); 55 55 else { … … 81 81 unsigned numMessagesPerProducer, 82 82 NotifyStyle notifyStyle, 83 std::chrono::microseconds timeout = std::chrono::microseconds::max(),84 std::chrono::microseconds delay = std::chrono::microseconds::zero())83 Seconds timeout = Seconds::infinity(), 84 Seconds delay = Seconds(0)) 85 85 { 86 86 Deque<unsigned> queue; … … 129 129 } 130 130 131 s td::this_thread::sleep_for(delay);131 sleep(delay); 132 132 133 133 for (unsigned i = numProducers; i--;) { … … 187 187 runTest( 188 188 1, 1, 1, 100000, TacticallyNotifyAll, 189 std::chrono::microseconds(10000),190 std::chrono::microseconds(1000000));189 Seconds::fromMilliseconds(10), 190 Seconds(1)); 191 191 } 192 192 … … 248 248 lock.lock(); 249 249 bool result = condition.waitFor( 250 lock, std::chrono::microseconds(10000), [] () -> bool { return false; });250 lock, Seconds::fromMilliseconds(10), [] () -> bool { return false; }); 251 251 lock.unlock(); 252 252 -
trunk/Tools/TestWebKitAPI/Tests/WTF/SynchronizedFixedQueue.cpp
r207156 r208415 117 117 118 118 m_lowerQueue.close(); 119 m_produceCloseSemaphore.wait( std::numeric_limits<double>::max());119 m_produceCloseSemaphore.wait(WallTime::infinity()); 120 120 m_produceQueue = nullptr; 121 121 } … … 127 127 128 128 m_upperQueue.close(); 129 m_consumeCloseSemaphore.wait( std::numeric_limits<double>::max());129 m_consumeCloseSemaphore.wait(WallTime::infinity()); 130 130 m_consumeQueue = nullptr; 131 131 }
Note: See TracChangeset
for help on using the changeset viewer.