OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple Inc. All rights reserved. |
3 * Copyright (C) 2007 Justin Haygood (jhaygood@reaktix.com) | 3 * Copyright (C) 2007 Justin Haygood (jhaygood@reaktix.com) |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 } | 235 } |
236 | 236 |
237 bool ThreadCondition::timedWait(Mutex& mutex, double absoluteTime) | 237 bool ThreadCondition::timedWait(Mutex& mutex, double absoluteTime) |
238 { | 238 { |
239 double currentTime = WTF::currentTime(); | 239 double currentTime = WTF::currentTime(); |
240 | 240 |
241 // Time is in the past - return immediately. | 241 // Time is in the past - return immediately. |
242 if (absoluteTime < currentTime) | 242 if (absoluteTime < currentTime) |
243 return false; | 243 return false; |
244 | 244 |
| 245 // Time is too far in the future (and would overflow unsigned long) - wait f
orever. |
| 246 if (absoluteTime - currentTime > static_cast<double>(INT_MAX) / 1000.0) { |
| 247 wait(mutex); |
| 248 return true; |
| 249 } |
| 250 |
245 double intervalMilliseconds = (absoluteTime - currentTime) * 1000.0; | 251 double intervalMilliseconds = (absoluteTime - currentTime) * 1000.0; |
246 // Qt defines wait for up to ULONG_MAX milliseconds. | |
247 if (intervalMilliseconds >= ULONG_MAX) | |
248 intervalMilliseconds = ULONG_MAX; | |
249 | |
250 return m_condition->wait(mutex.impl(), static_cast<unsigned long>(intervalMi
lliseconds)); | 252 return m_condition->wait(mutex.impl(), static_cast<unsigned long>(intervalMi
lliseconds)); |
251 } | 253 } |
252 | 254 |
253 void ThreadCondition::signal() | 255 void ThreadCondition::signal() |
254 { | 256 { |
255 m_condition->wakeOne(); | 257 m_condition->wakeOne(); |
256 } | 258 } |
257 | 259 |
258 void ThreadCondition::broadcast() | 260 void ThreadCondition::broadcast() |
259 { | 261 { |
260 m_condition->wakeAll(); | 262 m_condition->wakeAll(); |
261 } | 263 } |
262 | 264 |
263 } // namespace WebCore | 265 } // namespace WebCore |
OLD | NEW |