Changeset 44651 in webkit for trunk/JavaScriptCore/wtf
- Timestamp:
- Jun 13, 2009, 10:52:44 AM (16 years ago)
- Location:
- trunk/JavaScriptCore/wtf
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/wtf/Threading.h
r43663 r44651 127 127 #if USE(PTHREADS) 128 128 typedef pthread_mutex_t PlatformMutex; 129 typedef pthread_rwlock_t PlatformReadWriteLock; 129 130 typedef pthread_cond_t PlatformCondition; 130 131 #elif PLATFORM(GTK) 131 132 typedef GOwnPtr<GMutex> PlatformMutex; 133 typedef void* PlatformReadWriteLock; // FIXME: Implement. 132 134 typedef GOwnPtr<GCond> PlatformCondition; 133 135 #elif PLATFORM(QT) 134 136 typedef QT_PREPEND_NAMESPACE(QMutex)* PlatformMutex; 137 typedef void* PlatformReadWriteLock; // FIXME: Implement. 135 138 typedef QT_PREPEND_NAMESPACE(QWaitCondition)* PlatformCondition; 136 139 #elif PLATFORM(WIN_OS) … … 139 142 size_t m_recursionCount; 140 143 }; 144 typedef void* PlatformReadWriteLock; // FIXME: Implement. 141 145 struct PlatformCondition { 142 146 size_t m_waitersGone; … … 152 156 #else 153 157 typedef void* PlatformMutex; 158 typedef void* PlatformReadWriteLock; 154 159 typedef void* PlatformCondition; 155 160 #endif … … 171 176 172 177 typedef Locker<Mutex> MutexLocker; 178 179 class ReadWriteLock : Noncopyable { 180 public: 181 ReadWriteLock(); 182 ~ReadWriteLock(); 183 184 void readLock(); 185 bool tryReadLock(); 186 187 void writeLock(); 188 bool tryWriteLock(); 189 190 void unlock(); 191 192 private: 193 PlatformReadWriteLock m_readWriteLock; 194 }; 173 195 174 196 class ThreadCondition : Noncopyable { -
trunk/JavaScriptCore/wtf/ThreadingPthreads.cpp
r44504 r44651 268 268 } 269 269 270 271 ReadWriteLock::ReadWriteLock() 272 { 273 pthread_rwlock_init(&m_readWriteLock, NULL); 274 } 275 276 ReadWriteLock::~ReadWriteLock() 277 { 278 pthread_rwlock_destroy(&m_readWriteLock); 279 } 280 281 void ReadWriteLock::readLock() 282 { 283 int result = pthread_rwlock_rdlock(&m_readWriteLock); 284 ASSERT_UNUSED(result, !result); 285 } 286 287 bool ReadWriteLock::tryReadLock() 288 { 289 int result = pthread_rwlock_tryrdlock(&m_readWriteLock); 290 291 if (result == 0) 292 return true; 293 if (result == EBUSY || result == EAGAIN) 294 return false; 295 296 ASSERT_NOT_REACHED(); 297 return false; 298 } 299 300 void ReadWriteLock::writeLock() 301 { 302 int result = pthread_rwlock_wrlock(&m_readWriteLock); 303 ASSERT_UNUSED(result, !result); 304 } 305 306 bool ReadWriteLock::tryWriteLock() 307 { 308 int result = pthread_rwlock_trywrlock(&m_readWriteLock); 309 310 if (result == 0) 311 return true; 312 if (result == EBUSY || result == EAGAIN) 313 return false; 314 315 ASSERT_NOT_REACHED(); 316 return false; 317 } 318 319 void ReadWriteLock::unlock() 320 { 321 int result = pthread_rwlock_unlock(&m_readWriteLock); 322 ASSERT_UNUSED(result, !result); 323 } 324 270 325 ThreadCondition::ThreadCondition() 271 326 {
Note:
See TracChangeset
for help on using the changeset viewer.