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

Policy that drops the oldest item when queue is full. More...

#include <overflow_policies.h>

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

Public Types

using policy_tag = overflow_policy_tag
 

Public Member Functions

auto handle_overflow (std::unique_ptr< job > &&value) -> std::pair< bool, std::unique_ptr< job > >
 Handle overflow by requesting oldest item removal.
 

Static Public Member Functions

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

Detailed Description

Policy that drops the oldest item when queue is full.

When the queue is full, the oldest item (front of queue) is removed and discarded, making room for the new item.

Use Cases

  • Real-time systems where recent data is more valuable
  • Telemetry/metrics where latest values matter most
  • Caching scenarios with LRU-like behavior

Thread Safety

  • Thread-safe for concurrent access
  • Oldest item removal is atomic with new item insertion
Note
The dropped job's destructor will be called immediately

Definition at line 151 of file overflow_policies.h.

Member Typedef Documentation

◆ policy_tag

Member Function Documentation

◆ blocks()

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

Check if this policy blocks on overflow.

Returns
false (never blocks)

Definition at line 170 of file overflow_policies.h.

170 {
171 return false;
172 }

◆ drops_oldest()

static constexpr auto kcenon::thread::policies::overflow_drop_oldest_policy::drops_oldest ( ) -> bool
inlinestaticnodiscardconstexprnoexcept

Check if this policy drops items on overflow.

Returns
true (drops oldest)

Definition at line 178 of file overflow_policies.h.

178 {
179 return true;
180 }

◆ handle_overflow()

auto kcenon::thread::policies::overflow_drop_oldest_policy::handle_overflow ( std::unique_ptr< job > && value) -> std::pair<bool, std::unique_ptr<job>>
inlinenodiscard

Handle overflow by requesting oldest item removal.

Parameters
valueThe job to be added
Returns
Result indicating oldest should be dropped

Definition at line 160 of file overflow_policies.h.

161 {
162 // Return true to indicate oldest should be dropped
163 return {true, std::move(value)};
164 }

◆ name()

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

Get a descriptive name for this policy.

Returns
Policy name string

Definition at line 186 of file overflow_policies.h.

186 {
187 return "overflow_drop_oldest";
188 }

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