add subclass of ReadWriteMutex that avoids writer

---------------------------------------------------

                 Key: THRIFT-1272
                 URL: https://issues.apache.org/jira/browse/THRIFT-1272
             Project: Thrift
          Issue Type: Improvement
          Components: C++ - Library
            Reporter: Dave Watson
            Priority: Minor


>From e30d5bc332d7671ecaf3dd95fea1d8693506923d Mon Sep 17 00:00:00 2001
From: Doug Ihde <di...@fb.com>
Date: Mon, 22 Feb 2010 23:36:52 +0000
Subject: [PATCH 04/33] add subclass of ReadWriteMutex that avoids writer
 starvation

Summary: The ReadWriteMutex class does not guarantee that writers will not
         suffer from starvation. This new subclass provides such a
         guarantee.
         Also fixing a bug in ReadWriteMutex attemptRead() and
         attemptWrite() where the return value is the opposite of what is
         documented.



Test Plan: I wrote a simple program that launches 3 reader threads and 2
           writer thread to demonstrate the starvation. With a regular
           ReadWriteMutex, the writer threads never acquire the lock. With
           the new subclass, they acquire the lock as expected.



---
 lib/cpp/src/concurrency/Mutex.cpp  |   34 +++++++-
 lib/cpp/src/concurrency/Mutex.h    |   19 ++++
 lib/cpp/test/Makefile.am           |    5 +-
 lib/cpp/test/RWMutexStarveTest.cpp |  168 ++++++++++++++++++++++++++++++++++++
 4 files changed, 222 insertions(+), 4 deletions(-)
 create mode 100644 lib/cpp/test/RWMutexStarveTest.cpp



--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to