Skip to content

async: How does cross-task communication work? #459

Open
@alexcrichton

Description

@alexcrichton

I've talked with @lukewagner and @dicej in various degrees about this problem before, but I wanted to try to write up an issue with my thoughts about something concrete at least. At a high level I'm curious how an "async mutex" would work within a component, but I'm going to attempt to make this more specific as well.

Let's say I have a hypothetical setup like this:

  • Component A has an export, run.
  • An external entity (host or other component), calls run to create task T1.
  • Task T1 acquires an async mutex, but then decides it has taken too long and performs an async yield.
  • An external entity then calls run again to create task T2.
  • Task T2 attempts to acquire the mutex, sees that it's locked, and needs to block.
    • I'm assuming the callback ABI here, so this would return. Is this allowed? Returning while blocking on nothing?
  • The yield for T1 finishes and then it drops the lock.
    • How does this "wake up" T2? How is the "current task" context switched?

My vague undersatnding is that T2 traps when it returns waiting for the lock, but I'm also still booting up on all the canonical ABI pieces.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions