Skip to content

Phase 3 resource support: multi-token resources via oneTBB range-based limiter construction #853

Description

@knoepfel

Scope

Phase 3 enables multi-token resources: a resource that declares both a token_type and a tokens() member. Each returned token represents one concurrent access slot. A resource offering N tokens bounds a dependent node to at most N concurrent invocations, subject to its configured operator concurrency.

Phase 1 (#851) recognizes this form but rejects it at compile time. It must remain rejected until this phase is complete; Phlex must neither silently reduce a multi-token resource to one token nor emulate multi-token scheduling with a Phlex-specific semaphore.

oneTBB Dependency

The required iterator-range and container constructors for flow::resource_limiter were merged in oneTBB PR #2137. Phlex must wait for an official supported oneTBB release containing those constructors before enabling multi-token resources. Depending on an unreleased upstream branch or commit is out of scope.

Required Work

  1. Require an official supported oneTBB release containing the resource_limiter iterator-range or container constructor.
  2. Add a CMake feature probe for the required constructor.
  3. Materialize tokens() during resource registration and retain token values for the graph lifetime when their type requires it.
  4. Construct resource_limiter<T::token_type> from the complete token range or container.
  5. Reject an empty token collection at registration time. An empty limiter can leave graph::wait_for_all() blocked.
  6. Add tests proving that N tokens allow no more than N concurrent invocations and that multiple token identities are delivered and exercised.

Related Extension: Distinct Single Tokens

A separate extension may support a single token that is not derived from or equal to the registered resource type:

class database {
public:
  using token_type = database_connection*;

  token_type token();
};

The framework would use token() to construct the one-token limiter. This extension does not require runtime-sized oneTBB resource-limiter support and can be implemented independently of multi-token resources.

Activity

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions