Ignore:
Timestamp:
Jun 13, 2009, 10:52:44 AM (16 years ago)
Author:
[email protected]
Message:

2009-06-12 Dave Hyatt <[email protected]>

Reviewed by Anders Carlsson.

https://bugs.webkit.org/show_bug.cgi?id=26373

Add a new class to Threading in wtf called ReadWriteLock that handles single writer/multiple reader locking.
Provide a pthreads-only implementation of the lock for now, as this class is only going to be used
on Snow Leopard at first.

  • wtf/Threading.h: (WTF::ReadWriteLock::impl):
  • wtf/ThreadingPthreads.cpp: (WTF::ReadWriteLock::ReadWriteLock): (WTF::ReadWriteLock::~ReadWriteLock): (WTF::ReadWriteLock::readLock): (WTF::ReadWriteLock::tryReadLock): (WTF::ReadWriteLock::writeLock): (WTF::ReadWriteLock::tryWriteLock): (WTF::ReadWriteLock::unlock):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/wtf/Threading.h

    r43663 r44651  
    127127#if USE(PTHREADS)
    128128typedef pthread_mutex_t PlatformMutex;
     129typedef pthread_rwlock_t PlatformReadWriteLock;
    129130typedef pthread_cond_t PlatformCondition;
    130131#elif PLATFORM(GTK)
    131132typedef GOwnPtr<GMutex> PlatformMutex;
     133typedef void* PlatformReadWriteLock; // FIXME: Implement.
    132134typedef GOwnPtr<GCond> PlatformCondition;
    133135#elif PLATFORM(QT)
    134136typedef QT_PREPEND_NAMESPACE(QMutex)* PlatformMutex;
     137typedef void* PlatformReadWriteLock; // FIXME: Implement.
    135138typedef QT_PREPEND_NAMESPACE(QWaitCondition)* PlatformCondition;
    136139#elif PLATFORM(WIN_OS)
     
    139142    size_t m_recursionCount;
    140143};
     144typedef void* PlatformReadWriteLock; // FIXME: Implement.
    141145struct PlatformCondition {
    142146    size_t m_waitersGone;
     
    152156#else
    153157typedef void* PlatformMutex;
     158typedef void* PlatformReadWriteLock;
    154159typedef void* PlatformCondition;
    155160#endif
     
    171176
    172177typedef Locker<Mutex> MutexLocker;
     178
     179class ReadWriteLock : Noncopyable {
     180public:
     181    ReadWriteLock();
     182    ~ReadWriteLock();
     183
     184    void readLock();
     185    bool tryReadLock();
     186
     187    void writeLock();
     188    bool tryWriteLock();
     189   
     190    void unlock();
     191
     192private:
     193    PlatformReadWriteLock m_readWriteLock;
     194};
    173195
    174196class ThreadCondition : Noncopyable {
Note: See TracChangeset for help on using the changeset viewer.