Changeset 39908 in webkit for trunk/JavaScriptCore/wtf/ThreadingGtk.cpp
- Timestamp:
- Jan 14, 2009, 1:57:30 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/wtf/ThreadingGtk.cpp
r39487 r39908 33 33 #if !USE(PTHREADS) 34 34 35 #include "CurrentTime.h" 35 36 #include "HashMap.h" 36 37 #include "MainThread.h" … … 38 39 39 40 #include <glib.h> 41 #include <limits.h> 40 42 41 43 namespace WTF { … … 206 208 } 207 209 208 bool ThreadCondition::timedWait(Mutex& mutex, double interval) 209 { 210 if (interval < 0.0) { 210 bool ThreadCondition::timedWait(Mutex& mutex, double absoluteTime) 211 { 212 // Time is in the past - return right away. 213 if (absoluteTime < currentTime()) 214 return false; 215 216 // Time is too far in the future for g_cond_timed_wait - wait forever. 217 if (absoluteTime > INT_MAX) { 211 218 wait(mutex); 212 219 return true; 213 220 } 214 215 int intervalSeconds = static_cast<int>(interval);216 int intervalMicroseconds = static_cast<int>((interval - intervalSeconds) * 1000000.0);221 222 int timeSeconds = static_cast<int>(absoluteTime); 223 int timeMicroseconds = static_cast<int>((absoluteTime - timeSeconds) * 1000000.0); 217 224 218 225 GTimeVal targetTime; 219 g_get_current_time(&targetTime); 220 221 targetTime.tv_sec += intervalSeconds; 222 targetTime.tv_usec += intervalMicroseconds; 223 if (targetTime.tv_usec > 1000000) { 224 targetTime.tv_usec -= 1000000; 225 targetTime.tv_sec++; 226 } 226 targetTime.tv_sec = timeSeconds; 227 targetTime.tv_usec = timeMicroseconds; 227 228 228 229 return g_cond_timed_wait(m_condition.get(), mutex.impl().get(), &targetTime);
Note:
See TracChangeset
for help on using the changeset viewer.