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

Enforce safety rules for 'active' cypclasses

parent e9fbd755
......@@ -606,7 +606,7 @@ def inject_acthon_interfaces(self):
activable_scope.var_entries.append(activable_result_attr_entry)
activable_queue_attr_entry = activable_scope.declare("_active_queue_class", "_active_queue_class",
queue_type, None, "extern")
PyrexTypes.cyp_class_qualified_type(queue_type, 'locked'), None, "extern")
activable_queue_attr_entry.is_variable = 1
activable_scope.var_entries.append(activable_queue_attr_entry)
......
......@@ -875,7 +875,8 @@ class Scope(object):
# === Acthon ===
# Declare 'activate' function for this class
activate_func_arg = PyrexTypes.CFuncTypeArg(EncodedString("o"), entry.type, pos)
activate_func_arg_type = PyrexTypes.cyp_class_qualified_type(entry.type, 'iso')
activate_func_arg = PyrexTypes.CFuncTypeArg(EncodedString("o"), activate_func_arg_type, pos)
activate_func_return = PyrexTypes.cyp_class_qualified_type(entry.type, 'active')
activate_func_type = PyrexTypes.CFuncType(activate_func_return, [activate_func_arg], nogil = 1)
builtin_scope = scope.builtin_scope()
......@@ -2836,7 +2837,9 @@ class CppClassScope(Scope):
# create the active method type
activated_method_type = copy.copy(entry.type)
activated_method_type.return_type = result_type
activated_method_type.args = [activated_method_sync_attr_type] + entry.type.args
copied_args = (copy.copy(arg) for arg in entry.type.args)
sendable_args = [setattr(arg, 'type', viewpoint_adaptation(arg.type)) or arg for arg in copied_args]
activated_method_type.args = [activated_method_sync_attr_type] + sendable_args
# create the active method entry
activated_method_cname = "%s%s" % (Naming.cypclass_active_func_prefix, entry.cname)
activated_method_entry = Entry(entry.name, activated_method_cname, activated_method_type, entry.pos)
......
......@@ -134,7 +134,7 @@ cdef cypclass A activable:
__init__(self):
self.a = 0
self._active_result_class = WaitResult.construct
self._active_queue_class = BasicQueue()
self._active_queue_class = consume BasicQueue()
int getter(const self):
return self.a
void setter(self, int a):
......@@ -146,19 +146,19 @@ def test_acthon_chain(n):
42
"""
cdef ActhonResultInterface res
cdef ActhonQueueInterface queue
cdef locked ActhonQueueInterface queue
sync1 = ActivityCounterSync()
after_sync1 = ActivityCounterSync(sync1)
obj = A()
obj_actor = activate(obj)
queue = obj._active_queue_class
obj_actor = activate(consume obj)
# Pushing things in the queue
obj_actor.setter(sync1, n)
res = obj_actor.getter(after_sync1)
# Processing the queue
queue = obj._active_queue_class
while not queue.is_empty():
queue.activate()
print <int> res
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