Always fetch the promise JSValue and ID when we allocate one. Make it impossible that we've freed it before we return it. Hopefully fixes leaks. Definitely not worse for performance.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3758 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2022-01-14 03:05:37 +00:00
parent 27c2f27708
commit 0bcc7d8c59
5 changed files with 43 additions and 44 deletions

View File

@ -284,9 +284,10 @@ static void _taskstub_on_process_exit(uv_process_t* process, int64_t status, int
static JSValue _taskstub_getExports(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv)
{
tf_taskstub_t* stub = JS_GetOpaque(this_val, _classId);
promiseid_t promise = tf_task_allocate_promise(stub->_owner);
promiseid_t promise = -1;
JSValue result = tf_task_allocate_promise(stub->_owner, &promise);
tf_task_send_promise_message(stub->_owner, (tf_taskstub_t*)stub, kGetExports, promise, JS_UNDEFINED);
return tf_task_get_promise(stub->_owner, promise);
return result;
}
static JSValue _taskstub_setImports(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv)
@ -366,9 +367,10 @@ static JSValue _taskstub_activate(JSContext* context, JSValueConst this_val, int
static JSValue _taskstub_execute(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv)
{
tf_taskstub_t* stub = JS_GetOpaque(this_val, _classId);
promiseid_t promise = tf_task_allocate_promise(stub->_owner);
promiseid_t promise = -1;
JSValue result = tf_task_allocate_promise(stub->_owner, &promise);
tf_task_send_promise_message(stub->_owner, (tf_taskstub_t*)stub, kExecute, promise, argv[0]);
return tf_task_get_promise(stub->_owner, promise);
return result;
}
static JSValue _taskstub_kill(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv)