Fix Promise env longevity.
This commit is contained in:
parent
b54b93c7d1
commit
67691e36bc
|
@ -29,6 +29,7 @@ void cleanPromise(struct Promise* promise)
|
|||
{
|
||||
promise->refs -= 1;
|
||||
if (promise->refs == 0) {
|
||||
deleteEnv(promise->env);
|
||||
free(promise);
|
||||
}
|
||||
}
|
||||
|
@ -68,6 +69,7 @@ Object async(Object* params, int length, struct Environment* env)
|
|||
.env = env,
|
||||
.object = params[0], // TODO: Clone?
|
||||
};
|
||||
env->refs += 1;
|
||||
|
||||
pthread_create(&promise.promise->thread, NULL, doAsync, promise.promise);
|
||||
return promise;
|
||||
|
|
Loading…
Reference in New Issue