| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008, 2010 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 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 #ifndef ThreadingPrimitives_h | 31 #ifndef ThreadingPrimitives_h |
| 32 #define ThreadingPrimitives_h | 32 #define ThreadingPrimitives_h |
| 33 | 33 |
| 34 #include "wtf/Assertions.h" | 34 #include "wtf/Assertions.h" |
| 35 #include "wtf/FastAllocBase.h" | 35 #include "wtf/FastAllocBase.h" |
| 36 #include "wtf/Locker.h" | 36 #include "wtf/Locker.h" |
| 37 #include "wtf/Noncopyable.h" | 37 #include "wtf/Noncopyable.h" |
| 38 #include "wtf/WTFExport.h" | 38 #include "wtf/WTFExport.h" |
| 39 | 39 |
| 40 #if OS(WINDOWS) | 40 #if OS(WIN) |
| 41 #include <windows.h> | 41 #include <windows.h> |
| 42 #endif | 42 #endif |
| 43 | 43 |
| 44 #if USE(PTHREADS) | 44 #if USE(PTHREADS) |
| 45 #include <pthread.h> | 45 #include <pthread.h> |
| 46 #endif | 46 #endif |
| 47 | 47 |
| 48 namespace WTF { | 48 namespace WTF { |
| 49 | 49 |
| 50 #if USE(PTHREADS) | 50 #if USE(PTHREADS) |
| 51 typedef pthread_mutex_t PlatformMutex; | 51 typedef pthread_mutex_t PlatformMutex; |
| 52 typedef pthread_cond_t PlatformCondition; | 52 typedef pthread_cond_t PlatformCondition; |
| 53 #elif OS(WINDOWS) | 53 #elif OS(WIN) |
| 54 struct PlatformMutex { | 54 struct PlatformMutex { |
| 55 CRITICAL_SECTION m_internalMutex; | 55 CRITICAL_SECTION m_internalMutex; |
| 56 size_t m_recursionCount; | 56 size_t m_recursionCount; |
| 57 }; | 57 }; |
| 58 struct PlatformCondition { | 58 struct PlatformCondition { |
| 59 size_t m_waitersGone; | 59 size_t m_waitersGone; |
| 60 size_t m_waitersBlocked; | 60 size_t m_waitersBlocked; |
| 61 size_t m_waitersToUnblock; | 61 size_t m_waitersToUnblock; |
| 62 HANDLE m_blockLock; | 62 HANDLE m_blockLock; |
| 63 HANDLE m_blockQueue; | 63 HANDLE m_blockQueue; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 // Returns true if the condition was signaled before absoluteTime, false if
the absoluteTime was reached or is in the past. | 116 // Returns true if the condition was signaled before absoluteTime, false if
the absoluteTime was reached or is in the past. |
| 117 // The absoluteTime is in seconds, starting on January 1, 1970. The time is
assumed to use the same time zone as WTF::currentTime(). | 117 // The absoluteTime is in seconds, starting on January 1, 1970. The time is
assumed to use the same time zone as WTF::currentTime(). |
| 118 bool timedWait(Mutex&, double absoluteTime); | 118 bool timedWait(Mutex&, double absoluteTime); |
| 119 void signal(); | 119 void signal(); |
| 120 void broadcast(); | 120 void broadcast(); |
| 121 | 121 |
| 122 private: | 122 private: |
| 123 PlatformCondition m_condition; | 123 PlatformCondition m_condition; |
| 124 }; | 124 }; |
| 125 | 125 |
| 126 #if OS(WINDOWS) | 126 #if OS(WIN) |
| 127 // The absoluteTime is in seconds, starting on January 1, 1970. The time is assu
med to use the same time zone as WTF::currentTime(). | 127 // The absoluteTime is in seconds, starting on January 1, 1970. The time is assu
med to use the same time zone as WTF::currentTime(). |
| 128 // Returns an interval in milliseconds suitable for passing to one of the Win32
wait functions (e.g., ::WaitForSingleObject). | 128 // Returns an interval in milliseconds suitable for passing to one of the Win32
wait functions (e.g., ::WaitForSingleObject). |
| 129 DWORD absoluteTimeToWaitTimeoutInterval(double absoluteTime); | 129 DWORD absoluteTimeToWaitTimeoutInterval(double absoluteTime); |
| 130 #endif | 130 #endif |
| 131 | 131 |
| 132 } // namespace WTF | 132 } // namespace WTF |
| 133 | 133 |
| 134 using WTF::Mutex; | 134 using WTF::Mutex; |
| 135 using WTF::MutexLocker; | 135 using WTF::MutexLocker; |
| 136 using WTF::MutexTryLocker; | 136 using WTF::MutexTryLocker; |
| 137 using WTF::ThreadCondition; | 137 using WTF::ThreadCondition; |
| 138 | 138 |
| 139 #if OS(WINDOWS) | 139 #if OS(WIN) |
| 140 using WTF::absoluteTimeToWaitTimeoutInterval; | 140 using WTF::absoluteTimeToWaitTimeoutInterval; |
| 141 #endif | 141 #endif |
| 142 | 142 |
| 143 #endif // ThreadingPrimitives_h | 143 #endif // ThreadingPrimitives_h |
| OLD | NEW |