Commit ee853e23 authored by Gwenael Samain's avatar Gwenael Samain

API modification

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