Loading...
Searching...
No Matches
meshkit::native_detail::Work Struct Reference

Work-unit budget, workspace-estimate gate and cancellation poll for one operation. More...

#include </home/runner/work/Meshkit/Meshkit/src/native/operation.hpp>

Collaboration diagram for meshkit::native_detail::Work:

Public Member Functions

 Work (const Limits &l, const std::function< bool()> &c)
 Bind the limits and poll, set the allowance, and poll cancellation once.
 
void check () const
 Poll the cancellation callback.
 
void tick (std::uint64_t count=1)
 Charge work units; cancellation is polled whenever the updated total is an exact multiple of 4096.
 
void memoryFor (std::initializer_list< std::pair< std::uint64_t, std::uint64_t > > terms) const
 Gate a workspace estimate given as (count, bytes per item) terms.
 
void memory (std::uint64_t estimate) const
 Gate one workspace estimate; nothing is allocated or recorded.
 

Public Attributes

const Limits & limits
 Borrowed limits; maxWorkspaceBytes gates memory().
 
const std::function< bool()> & cancelled
 Borrowed cancellation poll; may be empty.
 
std::uint64_t used = 0
 Work units consumed so far by tick().
 
std::uint64_t maximum = 0
 Work-unit allowance: Limits::maxWork, or 20 billion when that is 0.
 

Detailed Description

Work-unit budget, workspace-estimate gate and cancellation poll for one operation.

Holds references to the caller's limits and callback, which must outlive it. Not thread-safe: one operation thread updates it.

Constructor & Destructor Documentation

◆ Work()

meshkit::native_detail::Work::Work ( const Limits & l,
const std::function< bool()> & c )
inline

Bind the limits and poll, set the allowance, and poll cancellation once.

Parameters
[in]lLimits, borrowed for the object's lifetime.
[in]cCancellation callback, borrowed for the object's lifetime; may be empty.
Exceptions
Stopcancelled (status Cancelled) when the poll already returns true.
Here is the call graph for this function:

Member Function Documentation

◆ check()

void meshkit::native_detail::Work::check ( ) const
inline

Poll the cancellation callback.

Exceptions
Stopcancelled (status Cancelled) when the callback is set and returns true.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ memory()

void meshkit::native_detail::Work::memory ( std::uint64_t estimate) const
inline

Gate one workspace estimate; nothing is allocated or recorded.

Parameters
[in]estimateEstimated bytes.
Exceptions
Stopworkspace_limit (status ResourceLimit) when estimate exceeds Limits::maxWorkspaceBytes.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ memoryFor()

void meshkit::native_detail::Work::memoryFor ( std::initializer_list< std::pair< std::uint64_t, std::uint64_t > > terms) const
inline

Gate a workspace estimate given as (count, bytes per item) terms.

Parameters
[in]termsPairs whose products are summed; nothing is allocated or recorded.
Exceptions
Stopworkspace_limit (status ResourceLimit) when the sum overflows 64 bits or exceeds Limits::maxWorkspaceBytes.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tick()

void meshkit::native_detail::Work::tick ( std::uint64_t count = 1)
inline

Charge work units; cancellation is polled whenever the updated total is an exact multiple of 4096.

Parameters
[in]countUnits to add.
Exceptions
Stopwork_limit (status ResourceLimit), leaving used unchanged, when the charge would exceed maximum; Stop cancelled from check().
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ cancelled

const std::function<bool()>& meshkit::native_detail::Work::cancelled

Borrowed cancellation poll; may be empty.

◆ limits

const Limits& meshkit::native_detail::Work::limits

Borrowed limits; maxWorkspaceBytes gates memory().

◆ maximum

std::uint64_t meshkit::native_detail::Work::maximum = 0

Work-unit allowance: Limits::maxWork, or 20 billion when that is 0.

◆ used

std::uint64_t meshkit::native_detail::Work::used = 0

Work units consumed so far by tick().


The documentation for this struct was generated from the following file: