106 default:
return "unknown";
124 default:
return "unknown";
368 return static_cast<double>(
jobs_accepted) /
static_cast<double>(total);
backpressure_decision
Decision returned by callback policy handler.
pressure_level
Current pressure level for graduated response.
backpressure_policy
Policy for handling queue overflow conditions.
@ drop_and_accept
Drop the oldest job, then accept new one.
@ accept
Accept the job into the queue.
@ reject
Reject with error (queue_full)
@ delay
Delay processing (attempt later)
@ none
Below low_watermark, queue is healthy.
@ low
Between low and high watermark.
@ critical
At or above max_size, queue is full.
@ high
Above high_watermark, approaching capacity.
@ drop_newest
Reject the new job when full.
@ block
Block until space is available (with timeout)
@ adaptive
Automatically adjust based on load conditions.
@ callback
Call user callback for custom decision.
@ drop_oldest
Drop the oldest job when full to make room.
Base job class for schedulable work units in the thread system.
Core threading foundation of the thread system library.
auto pressure_level_to_string(pressure_level level) -> std::string
Converts pressure_level to human-readable string.
auto backpressure_policy_to_string(backpressure_policy policy) -> std::string
Converts backpressure_policy to human-readable string.
@ queue_depth
Queue depth threshold exceeded.
Configuration for backpressure mechanisms.
backpressure_policy policy
The backpressure policy to use.
auto is_valid() const -> bool
Validates the configuration.
std::size_t rate_limit_tokens_per_second
Token refill rate (tokens added per second).
std::chrono::milliseconds adaptive_sample_interval
Sampling interval for adaptive mode.
double low_watermark
Low watermark threshold (percentage of max_size).
double high_watermark
High watermark threshold (percentage of max_size).
std::function< backpressure_decision(std::unique_ptr< job > &)> decision_callback
Custom decision callback for callback policy.
std::function< void(std::size_t queue_depth, double pressure_ratio)> pressure_callback
Callback for pressure events.
std::chrono::milliseconds block_timeout
Maximum time to block when using block policy.
std::size_t rate_limit_burst_size
Maximum tokens that can accumulate (burst capacity).
double adaptive_target_latency_ms
Target latency for adaptive mode (milliseconds).
bool enable_rate_limiting
Enable token bucket rate limiting.
Snapshot of backpressure statistics (copyable).
std::uint64_t rate_limit_waits
auto avg_block_time_ms() const -> double
Returns average block time per blocked operation.
std::uint64_t jobs_rejected
std::uint64_t jobs_accepted
std::uint64_t pressure_events
auto acceptance_rate() const -> double
Returns acceptance rate (accepted / total attempts).
std::uint64_t total_block_time_ns
std::uint64_t jobs_dropped
Thread-safe statistics for backpressure operations.
std::atomic< std::uint64_t > jobs_accepted
Total jobs accepted into the queue.
auto snapshot() const -> backpressure_stats_snapshot
Creates a copyable snapshot of current statistics.
std::atomic< std::uint64_t > jobs_dropped
Total jobs dropped (oldest dropped for new).
std::atomic< std::uint64_t > rate_limit_waits
Number of times rate limiting caused a wait.
auto reset() -> void
Resets all statistics to zero.
std::atomic< std::uint64_t > pressure_events
Number of times high watermark was crossed.
std::atomic< std::uint64_t > jobs_rejected
Total jobs rejected due to backpressure.
std::atomic< std::uint64_t > total_block_time_ns
Total time spent blocking in nanoseconds.