| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2009 Google Inc. All rights reserved. | 3 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 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 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 } | 450 } |
| 451 | 451 |
| 452 bool ThreadCondition::timedWait(Mutex& mutex, double absoluteTime) | 452 bool ThreadCondition::timedWait(Mutex& mutex, double absoluteTime) |
| 453 { | 453 { |
| 454 double currentTime = WTF::currentTime(); | 454 double currentTime = WTF::currentTime(); |
| 455 | 455 |
| 456 // Time is in the past - return immediately. | 456 // Time is in the past - return immediately. |
| 457 if (absoluteTime < currentTime) | 457 if (absoluteTime < currentTime) |
| 458 return false; | 458 return false; |
| 459 | 459 |
| 460 // Time is too far in the future (and would overflow unsigned long) - wait f
orever. |
| 461 if (absoluteTime - currentTime > static_cast<double>(INT_MAX) / 1000.0) { |
| 462 wait(mutex); |
| 463 return true; |
| 464 } |
| 465 |
| 460 double intervalMilliseconds = (absoluteTime - currentTime) * 1000.0; | 466 double intervalMilliseconds = (absoluteTime - currentTime) * 1000.0; |
| 461 if (intervalMilliseconds >= INT_MAX) | |
| 462 intervalMilliseconds = INT_MAX; | |
| 463 | |
| 464 return m_condition.timedWait(mutex.impl(), static_cast<unsigned long>(interv
alMilliseconds)); | 467 return m_condition.timedWait(mutex.impl(), static_cast<unsigned long>(interv
alMilliseconds)); |
| 465 } | 468 } |
| 466 | 469 |
| 467 void ThreadCondition::signal() | 470 void ThreadCondition::signal() |
| 468 { | 471 { |
| 469 m_condition.signal(false); // Unblock only 1 thread. | 472 m_condition.signal(false); // Unblock only 1 thread. |
| 470 } | 473 } |
| 471 | 474 |
| 472 void ThreadCondition::broadcast() | 475 void ThreadCondition::broadcast() |
| 473 { | 476 { |
| 474 m_condition.signal(true); // Unblock all threads. | 477 m_condition.signal(true); // Unblock all threads. |
| 475 } | 478 } |
| 476 | 479 |
| 477 } // namespace WTF | 480 } // namespace WTF |
| OLD | NEW |