Changeset 39908 in webkit for trunk/JavaScriptCore/wtf/ThreadingPthreads.cpp
- Timestamp:
- Jan 14, 2009, 1:57:30 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/wtf/ThreadingPthreads.cpp
r39487 r39908 34 34 #if USE(PTHREADS) 35 35 36 #include "CurrentTime.h" 36 37 #include "HashMap.h" 37 38 #include "MainThread.h" … … 233 234 } 234 235 235 bool ThreadCondition::timedWait(Mutex& mutex, double secondsToWait) 236 { 237 if (secondsToWait < 0.0) { 236 bool ThreadCondition::timedWait(Mutex& mutex, double absoluteTime) 237 { 238 if (absoluteTime < currentTime()) 239 return false; 240 241 if (absoluteTime > INT_MAX) { 238 242 wait(mutex); 239 243 return true; 240 244 } 241 245 242 int intervalSeconds = static_cast<int>(secondsToWait); 243 int intervalMicroseconds = static_cast<int>((secondsToWait - intervalSeconds) * 1000000.0); 244 245 // Current time comes in sec/microsec 246 timeval currentTime; 247 gettimeofday(¤tTime, NULL); 248 249 // Target time comes in sec/nanosec 246 int timeSeconds = static_cast<int>(absoluteTime); 247 int timeNanoseconds = static_cast<int>((absoluteTime - timeSeconds) * 1E9); 248 250 249 timespec targetTime; 251 targetTime.tv_sec = currentTime.tv_sec + intervalSeconds; 252 targetTime.tv_nsec = (currentTime.tv_usec + intervalMicroseconds) * 1000; 253 if (targetTime.tv_nsec > 1000000000) { 254 targetTime.tv_nsec -= 1000000000; 255 targetTime.tv_sec++; 256 } 250 targetTime.tv_sec = timeSeconds; 251 targetTime.tv_nsec = timeNanoseconds; 257 252 258 253 return pthread_cond_timedwait(&m_condition, &mutex.impl(), &targetTime) == 0;
Note:
See TracChangeset
for help on using the changeset viewer.