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

Added pending jobs handling API to Runtime #2

Closed
wants to merge 1 commit into from

Conversation

katyo
Copy link
Collaborator

@katyo katyo commented Nov 11, 2020

I added missing APIs to execute pending jobs in queue.
This is required for handling async stuff like promises and generators.

Copy link
Owner

@DelSkayn DelSkayn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes allows one to trigger undefined behavior from safe code.
See comments for specifics.

/// Execute first pending job
///
/// Returns context for executed job or none when queue is empty or error when exception thrown under execution.
pub fn execute_pending_job(&self) -> Result<Option<Ctx<'_>>, Error> {
Copy link
Owner

@DelSkayn DelSkayn Nov 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ctx should not be available outside a callback handed to Context::with otherwise the runtime can be accessed outside the mutex guard, which is unsafe.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This functions should probably be a member of Ctx.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By design QuickJS has single queue per runtime, so this function cannot be member of Ctx.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My next pr #6 supersede this, I already changed returning value.

@DelSkayn
Copy link
Owner

Closed, resolved in later pull request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants