Commit 2fd7bc9f authored by Xavier Thompson's avatar Xavier Thompson

Change acthon interfaces

parent 98a93bc2
......@@ -510,9 +510,8 @@ def inject_acthon_interfaces(self):
sync_isCompleted_entry.is_variable = 1
sync_scope.var_entries.append(sync_isCompleted_entry)
sync_msg_arg = PyrexTypes.CFuncTypeArg("msg", message_type, None)
sync_insertActivity_type = PyrexTypes.CFuncType(PyrexTypes.c_void_type, [sync_msg_arg], nogil = 1)
sync_removeActivity_type = PyrexTypes.CFuncType(PyrexTypes.c_void_type, [sync_msg_arg], nogil = 1)
sync_insertActivity_type = PyrexTypes.CFuncType(PyrexTypes.c_void_type, [], nogil = 1)
sync_removeActivity_type = PyrexTypes.CFuncType(PyrexTypes.c_void_type, [], nogil = 1)
sync_insertActivity_entry = sync_scope.declare("insertActivity", "insertActivity",
sync_insertActivity_type, None, "extern")
sync_insertActivity_entry.is_cfunction = 1
......@@ -533,12 +532,12 @@ def inject_acthon_interfaces(self):
message_entry.is_type = 1
message_sync_attr_entry = message_scope.declare("_sync_method", "_sync_method",
sync_type, None, "extern")
PyrexTypes.cyp_class_qualified_type(sync_type, 'locked'), None, "extern")
message_sync_attr_entry.is_variable = 1
message_scope.var_entries.append(message_sync_attr_entry)
message_result_attr_entry = message_scope.declare("_result", "_result",
result_type, None, "extern")
PyrexTypes.cyp_class_qualified_type(result_type, 'locked'), None, "extern")
message_result_attr_entry.is_variable = 1
message_scope.var_entries.append(message_result_attr_entry)
......@@ -564,7 +563,7 @@ def inject_acthon_interfaces(self):
queue_entry.is_type = 1
queue_msg_arg = PyrexTypes.CFuncTypeArg("msg", message_type, None)
queue_push_type = PyrexTypes.CFuncType(PyrexTypes.c_void_type, [queue_msg_arg], nogil = 1)
queue_push_type = PyrexTypes.CFuncType(PyrexTypes.c_void_type, [queue_msg_arg], nogil = 1, self_qualifier = 'locked&')
queue_push_entry = queue_scope.declare("push", "push", queue_push_type,
None, "extern")
queue_push_entry.is_cfunction = 1
......
......@@ -2850,7 +2850,7 @@ class CppClassScope(Scope):
# create the sync argument type
activated_method_sync_attr_type = PyrexTypes.CFuncTypeArg(
EncodedString("sync_method"),
PyrexTypes.CConstOrVolatileType(sync_type, is_const=1),
PyrexTypes.cyp_class_qualified_type(sync_type, 'locked'),
entry.pos,
"sync_method",
)
......
......@@ -364,8 +364,8 @@
struct ActhonSyncInterface : public CyObject {
virtual int isActivable() const = 0;
virtual int isCompleted() const = 0;
virtual void insertActivity(ActhonMessageInterface* msg) = 0;
virtual void removeActivity(ActhonMessageInterface* msg) = 0;
virtual void insertActivity() = 0;
virtual void removeActivity() = 0;
};
struct ActhonMessageInterface : public CyObject {
......
......@@ -26,10 +26,10 @@ cdef cypclass BasicQueue(ActhonQueueInterface):
bint is_empty(const self):
return self._queue.empty()
void push(self, ActhonMessageInterface message):
void push(locked& self, ActhonMessageInterface message):
self._queue.push_back(message)
if message._sync_method is not NULL:
message._sync_method.insertActivity(message)
message._sync_method.insertActivity()
bint activate(self):
cdef bint one_message_processed
......@@ -47,7 +47,7 @@ cdef cypclass BasicQueue(ActhonQueueInterface):
if next_message._sync_method is not NULL:
next_sync_method = next_message._sync_method
with wlocked next_sync_method:
next_sync_method.removeActivity(next_message)
next_sync_method.removeActivity()
else:
self._queue.push_back(next_message)
# Don't forget to incref to avoid premature deallocation
......@@ -106,16 +106,16 @@ cdef cypclass WaitResult(ActhonResultInterface):
cdef cypclass ActivityCounterSync(ActhonSyncInterface):
int count
ActivityCounterSync previous_sync
locked ActivityCounterSync previous_sync
__init__(self, ActivityCounterSync prev = <ActivityCounterSync> NULL):
__init__(self, locked ActivityCounterSync prev = NULL):
self.count = 0
self.previous_sync = prev
void insertActivity(self, ActhonMessageInterface msg):
void insertActivity(self):
self.count += 1
void removeActivity(self, ActhonMessageInterface msg):
void removeActivity(self):
self.count -= 1
bint isCompleted(const self):
......@@ -147,8 +147,8 @@ def test_acthon_chain(n):
"""
cdef ActhonResultInterface res
cdef locked ActhonQueueInterface queue
sync1 = ActivityCounterSync()
after_sync1 = ActivityCounterSync(sync1)
sync1 = <locked ActivityCounterSync> consume ActivityCounterSync()
after_sync1 = <locked ActivityCounterSync> consume ActivityCounterSync(sync1)
obj = A()
queue = obj._active_queue_class
......
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