Skip to content

async: let an around-task hook tell a resumption from a posted callable #53

Description

@christianparpart

StrandOptions::aroundTask / KeyedAroundTask<Key> receive a RunTask that wraps a private StrandTask* and exposes only operator(). A hook therefore cannot tell a coroutine resumption from a posted callable.

Why it matters: morph (LASTRADA-Software/morph#806) installs a Task handler's morph::session through the keyed hook. While a handler is suspended, its session reaches every task on that model's key, including onBackendChanged and a queued action until that action installs its own session. morph documents this. A resumption-only session would be tighter.

Proposal: add [[nodiscard]] bool RunTask::isResumption() const noexcept, or a TaskKind enum, so a hook can apply per-resumption context only to coroutine resumptions.

  • Cost: none on the path where no hook is set; one load where a hook is set.
  • Tests: the hook observes the kind for a post, a submit(handle) and a submit(ParkedWork).

Not needed for 0.4.x correctness. This is a precision improvement for consumers of the hook.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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