Allow providing a non-standard condition class to the r/w lock

This commit is contained in:
Joshua Harlow
2015-06-06 23:36:15 -07:00
parent c33c6d6a12
commit fbe817bb25
2 changed files with 7 additions and 3 deletions

View File

@@ -1,4 +1,7 @@
0.9
0.9:
- Allow providing a non-standard (eventlet or
other condition class) to the r/w lock for
cases where it is useful to do so.
0.8:
- Add fastener logo (from openclipart).
- Ensure r/w writer -> reader -> writer

View File

@@ -132,11 +132,12 @@ class ReaderWriterLock(object):
return eventlet.getcurrent
return threading.current_thread
def __init__(self, find_eventlet=True):
def __init__(self, find_eventlet=True,
condition_cls=threading.Condition):
self._writer = None
self._pending_writers = collections.deque()
self._readers = collections.deque()
self._cond = threading.Condition()
self._cond = condition_cls()
self._current_thread = self._fetch_current_thread_functor(
find_eventlet=find_eventlet)