Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ecma_free_all_enqueued_jobs function #2265

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions jerry-core/api/jerry.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ jerry_cleanup (void)
jmem_heap_free_block (this_p, sizeof (jerry_context_data_header_t) + this_p->manager_p->bytes_needed);
}

#ifndef CONFIG_DISABLE_ES2015_PROMISE_BUILTIN
ecma_free_all_enqueued_jobs ();
#endif /* CONFIG_DISABLE_ES2015_PROMISE_BUILTIN */
ecma_finalize ();
jmem_finalize ();
jerry_make_api_unavailable ();
Expand Down
17 changes: 17 additions & 0 deletions jerry-core/ecma/operations/ecma-jobqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,23 @@ ecma_process_all_enqueued_jobs (void)
return ret;
} /* ecma_process_all_enqueued_jobs */

/**
* Release enqueued Promise jobs.
*/
void
ecma_free_all_enqueued_jobs (void)
{
while (JERRY_CONTEXT (job_queue_head_p) != NULL)
{
ecma_job_queueitem_t *item_p = JERRY_CONTEXT (job_queue_head_p);
JERRY_CONTEXT (job_queue_head_p) = item_p->next_p;
void *job_p = item_p->job_p;
jmem_heap_free_block (item_p, sizeof (ecma_job_queueitem_t));

ecma_free_promise_reaction_job (job_p);
}
} /* ecma_free_all_enqueued_jobs */

/**
* @}
* @}
Expand Down
1 change: 1 addition & 0 deletions jerry-core/ecma/operations/ecma-jobqueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ void ecma_job_queue_init (void);

void ecma_enqueue_promise_reaction_job (ecma_value_t reaction, ecma_value_t argument);
void ecma_enqueue_promise_resolve_thenable_job (ecma_value_t promise, ecma_value_t thenable, ecma_value_t then);
void ecma_free_all_enqueued_jobs (void);

ecma_value_t ecma_process_all_enqueued_jobs (void);

Expand Down