Commit ee853e23 authored by Gwenael Samain's avatar Gwenael Samain

API modification

parent 92a4c485
...@@ -4,14 +4,16 @@ from posix.unistd cimport sleep ...@@ -4,14 +4,16 @@ from posix.unistd cimport sleep
cdef extern from "Python.h": cdef extern from "Python.h":
void Cy_INCREF(cyobject o) nogil void Cy_INCREF(cyobject o) nogil
cdef cypclass MessageInterface nolock
cdef cypclass SyncInterface nolock: cdef cypclass SyncInterface nolock:
bint isActivable(self): bint isActivable(self):
pass pass
bint isCompleted(self): bint isCompleted(self):
pass pass
void insert_activity(self): void insert_activity(self, MessageInterface msg):
pass pass
void remove_activity(self): void remove_activity(self, MessageInterface msg):
pass pass
cdef cypclass MessageInterface nolock: cdef cypclass MessageInterface nolock:
...@@ -57,7 +59,7 @@ cdef cypclass BasicQueue(QueueInterface) nolock: ...@@ -57,7 +59,7 @@ cdef cypclass BasicQueue(QueueInterface) nolock:
self._queue.push_back(message) self._queue.push_back(message)
if message._sync_method is not NULL: if message._sync_method is not NULL:
# prototype must change # prototype must change
message._sync_method.insert_activity() message._sync_method.insert_activity(message)
# incref message # incref message
Cy_INCREF(message) Cy_INCREF(message)
# unlock queue # unlock queue
...@@ -81,7 +83,7 @@ cdef cypclass BasicQueue(QueueInterface) nolock: ...@@ -81,7 +83,7 @@ cdef cypclass BasicQueue(QueueInterface) nolock:
with gil: with gil:
print("Top message processed, reporting to result class & deallocating") print("Top message processed, reporting to result class & deallocating")
if next_message._sync_method is not NULL: if next_message._sync_method is not NULL:
next_message._sync_method.remove_activity() next_message._sync_method.remove_activity(next_message)
#del next_message #del next_message
else: else:
with gil: with gil:
...@@ -160,12 +162,12 @@ cdef cypclass ActivityCounterSync(SyncInterface) nolock: ...@@ -160,12 +162,12 @@ cdef cypclass ActivityCounterSync(SyncInterface) nolock:
self.count = 0 self.count = 0
self.previous_sync = prev self.previous_sync = prev
void insert_activity(self): void insert_activity(self, MessageInterface msg):
# lock self # lock self
self.count += 1 self.count += 1
# unlock self # unlock self
void remove_activity(self): void remove_activity(self, MessageInterface msg):
# lock self # lock self
self.count -= 1 self.count -= 1
# unlock self # unlock self
......
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