Changeset 30849 in webkit for trunk/JavaScriptCore/wtf/ThreadingPthreads.cpp
- Timestamp:
- Mar 6, 2008, 10:55:02 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/wtf/ThreadingPthreads.cpp
r30842 r30849 33 33 34 34 #include <errno.h> 35 #include <time.h> 35 36 36 37 namespace WTF { … … 185 186 ASSERT(false); 186 187 } 187 188 189 bool ThreadCondition::timedWait(Mutex& mutex, double interval) 190 { 191 if (interval < 0.0) { 192 wait(mutex); 193 return true; 194 } 195 196 int intervalSeconds = static_cast<int>(interval); 197 int intervalMicroseconds = static_cast<int>((interval - intervalSeconds) * 1000000.0); 198 199 // Current time comes in sec/microsec 200 timeval currentTime; 201 gettimeofday(¤tTime, NULL); 202 203 // Target time comes in sec/nanosec 204 timespec targetTime; 205 targetTime.tv_sec = currentTime.tv_sec + intervalSeconds; 206 targetTime.tv_nsec = (currentTime.tv_usec + intervalMicroseconds) * 1000; 207 if (targetTime.tv_nsec > 1000000000) { 208 targetTime.tv_nsec -= 1000000000; 209 targetTime.tv_sec++; 210 } 211 212 return pthread_cond_timedwait(&m_condition, &mutex.impl(), &targetTime) == 0; 213 } 214 188 215 void ThreadCondition::signal() 189 216 {
Note:
See TracChangeset
for help on using the changeset viewer.