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_block_policy Class Reference

Policy that blocks until space is available. More...

#include <overflow_policies.h>

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

Public Types

using policy_tag = overflow_policy_tag
 

Public Member Functions

auto handle_overflow (std::unique_ptr< job > &&value) -> std::pair< common::VoidResult, std::unique_ptr< job > >
 Handle overflow by indicating need to wait.
 

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 blocks until space is available.

When the queue is full, the enqueue operation blocks until another thread dequeues an item, making space available.

Use Cases

  • Backpressure scenarios where producers should slow down
  • Bounded buffers between producer-consumer pairs
  • Flow control where no items should be lost

Thread Safety

  • Thread-safe blocking using condition variables
  • Safe for multiple concurrent producers
Warning
This policy requires the sync policy to support blocking waits. It will not work correctly with lock-free sync policies.

Definition at line 98 of file overflow_policies.h.

Member Typedef Documentation

◆ policy_tag

Member Function Documentation

◆ blocks()

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

Check if this policy blocks on overflow.

Returns
true (always blocks)

Definition at line 120 of file overflow_policies.h.

120 {
121 return true;
122 }

◆ handle_overflow()

auto kcenon::thread::policies::overflow_block_policy::handle_overflow ( std::unique_ptr< job > && value) -> std::pair<common::VoidResult, std::unique_ptr<job>>
inlinenodiscard

Handle overflow by indicating need to wait.

Parameters
valueThe job to be added (returned unchanged)
Returns
Special result indicating blocking is needed
Note
The actual blocking is implemented by the queue template

Definition at line 109 of file overflow_policies.h.

110 {
111 // Return the job back to the caller for retry after waiting
112 return {common::error_info{-123, "queue full, waiting for space", "thread_system"},
113 std::move(value)};
114 }

◆ name()

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

Get a descriptive name for this policy.

Returns
Policy name string

Definition at line 128 of file overflow_policies.h.

128 {
129 return "overflow_block";
130 }

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