Thread System 0.3.1
High-performance C++20 thread pool with work stealing and DAG scheduling
Loading...
Searching...
No Matches
kcenon::thread::policies::overflow_reject_policy Class Reference

Policy that rejects new items when queue is full. More...

#include <overflow_policies.h>

Collaboration diagram for kcenon::thread::policies::overflow_reject_policy:
Collaboration graph

Public Types

using policy_tag = overflow_policy_tag
 

Public Member Functions

auto handle_overflow (std::unique_ptr< job > &&) -> common::VoidResult
 Handle overflow by rejecting the new item.
 

Static Public Member Functions

static constexpr auto blocks () noexcept -> bool
 Check if this policy blocks on overflow.
 
static constexpr auto name () noexcept -> const char *
 Get a descriptive name for this policy.
 

Detailed Description

Policy that rejects new items when queue is full.

When the queue is full, enqueue operations immediately fail with an error. The new item is not added to the queue.

Use Cases

  • Fast-fail scenarios where dropping new work is acceptable
  • Load shedding where overflow should be handled by caller
  • Non-blocking producers that check result

Usage

auto result = queue.enqueue(make_job());
if (result.is_err()) {
// Handle overflow - job was rejected
}
Policy-based queue template.
A template class representing either a value or an error.
auto make_job() -> job_builder

Definition at line 48 of file overflow_policies.h.

Member Typedef Documentation

◆ policy_tag

Member Function Documentation

◆ blocks()

static constexpr auto kcenon::thread::policies::overflow_reject_policy::blocks ( ) -> bool
inlinestaticnodiscardconstexprnoexcept

Check if this policy blocks on overflow.

Returns
false (never blocks)

Definition at line 66 of file overflow_policies.h.

66 {
67 return false;
68 }

◆ handle_overflow()

auto kcenon::thread::policies::overflow_reject_policy::handle_overflow ( std::unique_ptr< job > && ) -> common::VoidResult
inlinenodiscard

Handle overflow by rejecting the new item.

Parameters
valueThe job that would be added (will be dropped)
Returns
Error indicating queue is full

Definition at line 57 of file overflow_policies.h.

58 {
59 return common::error_info{-120, "queue is full, rejecting new item", "thread_system"};
60 }

◆ name()

static constexpr auto kcenon::thread::policies::overflow_reject_policy::name ( ) -> const char*
inlinestaticnodiscardconstexprnoexcept

Get a descriptive name for this policy.

Returns
Policy name string

Definition at line 74 of file overflow_policies.h.

74 {
75 return "overflow_reject";
76 }

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