From 7f515113fa3a465a5af6ed5e87fab84788683f0c Mon Sep 17 00:00:00 2001 From: Robert Nishihara Date: Fri, 7 Oct 2016 15:20:56 -0700 Subject: [PATCH] Generate return object IDs in the task constructor. (#36) --- lib/python/common_extension.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/python/common_extension.c b/lib/python/common_extension.c index 46ae9e560..efc4b9e01 100644 --- a/lib/python/common_extension.c +++ b/lib/python/common_extension.c @@ -131,6 +131,7 @@ static int PyTask_init(PyTask *self, PyObject *args, PyObject *kwds) { int val_repr_index = 0; self->spec = alloc_task_spec(function_id, size, num_returns, value_data_bytes); + /* Add the task arguments. */ for (size_t i = 0; i < size; ++i) { PyObject *arg = PyList_GetItem(arguments, i); if (PyObject_IsInstance(arg, (PyObject *) &PyObjectIDType)) { @@ -145,6 +146,14 @@ static int PyTask_init(PyTask *self, PyObject *args, PyObject *kwds) { } } utarray_free(val_repr_ptrs); + /* Generate and add the object IDs for the return values. */ + for (size_t i = 0; i < num_returns; ++i) { + /* TODO(rkn): Later, this should be computed as a deterministic hash of (1) + * the contents of the task, (2) the index i, and (3) a counter of the + * number of tasks launched so far by the parent task. For now, we generate + * it randomly. */ + *task_return(self->spec, i) = globally_unique_id(); + } return 0; }