Skip to content

Only one thread can access the same context at a given time #25

@jeromegn

Description

@jeromegn

This was non-obvious to me since I have experience with V8 which takes care of synchronization for you.

Before setting a context, you might need to unset the current one. Which is what your ContextGuard does as it is dropped. Except it doesn't prevent another thread from trying to set the same context concurrently.

I was thinking an Arc<Mutex<()>> might work for entering a context.

I'm not sure what's the logic with setting the "previous" context as the current context from the Context#exit method. I'm assuming people won't be using more than 1 context per runtime, so inner guards are probably infrequent.

Any ideas?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions