Commit 228ffec9 authored by Xavier Thompson's avatar Xavier Thompson

Adapt existing cypclass locking unit tests

parent 5aef3d90
...@@ -26,10 +26,10 @@ def incorrect_locks(): ...@@ -26,10 +26,10 @@ def incorrect_locks():
take_read_locked(obj) take_read_locked(obj)
_ERRORS = u""" _ERRORS = u"""
20:4: This expression is not correctly locked (write lock needed) 20:4: Reference 'obj' is not correctly locked in this expression (write lock required)
21:4: This expression is not correctly locked (read lock needed) 21:4: Reference 'obj' is not correctly locked in this expression (read lock required)
23:8: This expression is not correctly locked (write lock needed) 23:8: Reference 'obj' is not correctly locked in this expression (write lock required)
24:26: This expression is not correctly locked (write lock needed) 24:26: Reference 'obj' is not correctly locked in this expression (write lock required)
25:4: This expression is not correctly locked (read lock needed) 25:4: Reference 'obj' is not correctly locked in this expression (read lock required)
26:21: This expression is not correctly locked (read lock needed) 26:21: Reference 'obj' is not correctly locked in this expression (write lock required)
""" """
...@@ -46,8 +46,9 @@ cdef cypclass BasicQueue(ActhonQueueInterface) checklock: ...@@ -46,8 +46,9 @@ cdef cypclass BasicQueue(ActhonQueueInterface) checklock:
one_message_processed = next_message.activate() one_message_processed = next_message.activate()
if one_message_processed: if one_message_processed:
if next_message._sync_method is not NULL: if next_message._sync_method is not NULL:
with wlocked next_message._sync_method: next_sync_method = next_message._sync_method
next_message._sync_method.removeActivity(next_message) with wlocked next_sync_method:
next_sync_method.removeActivity(next_message)
else: else:
self._queue.push_back(next_message) self._queue.push_back(next_message)
# Don't forget to incref to avoid premature deallocation # Don't forget to incref to avoid premature deallocation
...@@ -125,8 +126,9 @@ cdef cypclass ActivityCounterSync(ActhonSyncInterface) checklock: ...@@ -125,8 +126,9 @@ cdef cypclass ActivityCounterSync(ActhonSyncInterface) checklock:
bint isActivable(self) const: bint isActivable(self) const:
cdef bint res = True cdef bint res = True
if self.previous_sync is not NULL: if self.previous_sync is not NULL:
with rlocked self.previous_sync: prev_sync = self.previous_sync
res = self.previous_sync.isCompleted() with rlocked prev_sync:
res = prev_sync.isCompleted()
return res return res
cdef cypclass A checklock activable: cdef cypclass A checklock activable:
......
...@@ -69,6 +69,8 @@ def test_lock_traversal(n): ...@@ -69,6 +69,8 @@ def test_lock_traversal(n):
42 42
""" """
container = Container() container = Container()
with rlocked container, wlocked container.object: with rlocked container:
argument_recursivity(container.object, n) contained = container.object
print container.object.getter() 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