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
- Require an official supported oneTBB release containing the
resource_limiter iterator-range or container constructor.
- Add a CMake feature probe for the required constructor.
- Materialize
tokens() during resource registration and retain token values for the graph lifetime when their type requires it.
- Construct
resource_limiter<T::token_type> from the complete token range or container.
- Reject an empty token collection at registration time. An empty limiter can leave
graph::wait_for_all() blocked.
- 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.
Scope
Phase 3 enables multi-token resources: a resource that declares both a
token_typeand atokens()member. Each returned token represents one concurrent access slot. A resource offeringNtokens bounds a dependent node to at mostNconcurrent 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_limiterwere 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
resource_limiteriterator-range or container constructor.tokens()during resource registration and retain token values for the graph lifetime when their type requires it.resource_limiter<T::token_type>from the complete token range or container.graph::wait_for_all()blocked.Ntokens allow no more thanNconcurrent 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:
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.