Commit 89542a57 authored by Xavier Thompson's avatar Xavier Thompson

Adapt existing cypclass locking unit tests

parent 5899fd3d
......@@ -26,10 +26,10 @@ def incorrect_locks():
take_read_locked(obj)
_ERRORS = u"""
20:4: This expression is not correctly locked (write lock needed)
21:4: This expression is not correctly locked (read lock needed)
23:8: This expression is not correctly locked (write lock needed)
24:26: This expression is not correctly locked (write lock needed)
25:4: This expression is not correctly locked (read lock needed)
26:21: This expression is not correctly locked (read lock needed)
20:4: Reference 'obj' is not correctly locked in this expression (write lock required)
21:4: Reference 'obj' is not correctly locked in this expression (read lock required)
23:8: Reference 'obj' is not correctly locked in this expression (write lock required)
24:26: Reference 'obj' is not correctly locked in this expression (write lock required)
25:4: Reference 'obj' is not correctly locked in this expression (read lock required)
26:21: Reference 'obj' is not correctly locked in this expression (write lock required)
"""
......@@ -46,8 +46,9 @@ cdef cypclass BasicQueue(ActhonQueueInterface) checklock:
one_message_processed = next_message.activate()
if one_message_processed:
if next_message._sync_method is not NULL:
with wlocked next_message._sync_method:
next_message._sync_method.removeActivity(next_message)
next_sync_method = next_message._sync_method
with wlocked next_sync_method:
next_sync_method.removeActivity(next_message)
else:
self._queue.push_back(next_message)
# Don't forget to incref to avoid premature deallocation
......@@ -125,8 +126,9 @@ cdef cypclass ActivityCounterSync(ActhonSyncInterface) checklock:
bint isActivable(self) const:
cdef bint res = True
if self.previous_sync is not NULL:
with rlocked self.previous_sync:
res = self.previous_sync.isCompleted()
prev_sync = self.previous_sync
with rlocked prev_sync:
res = prev_sync.isCompleted()
return res
cdef cypclass A checklock activable:
......
......@@ -69,6 +69,8 @@ def test_lock_traversal(n):
42
"""
container = Container()
with rlocked container, wlocked container.object:
argument_recursivity(container.object, n)
print container.object.getter()
with rlocked container:
contained = container.object
with wlocked contained:
argument_recursivity(contained, n)
print contained.getter()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment