ThreadSchedule 1.0.0
Modern C++ thread management library
Loading...
Searching...
No Matches
threadschedule::ThreadRegistry::QueryView Class Reference

Lazy, functional-style query/filter view over a snapshot of registered threads. More...

#include <thread_registry.hpp>

Public Member Functions

 QueryView (std::vector< RegisteredThreadInfo > entries)
template<typename Predicate>
auto filter (Predicate &&pred) const -> QueryView
template<typename Fn>
void for_each (Fn &&fn) const
auto count () const -> size_t
auto empty () const -> bool
auto entries () const -> std::vector< RegisteredThreadInfo > const &
template<typename Fn>
auto map (Fn &&fn) const -> std::vector< std::invoke_result_t< Fn, RegisteredThreadInfo const & > >
template<typename Predicate>
auto find_if (Predicate &&pred) const -> std::optional< RegisteredThreadInfo >
template<typename Predicate>
auto any (Predicate &&pred) const -> bool
template<typename Predicate>
auto all (Predicate &&pred) const -> bool
template<typename Predicate>
auto none (Predicate &&pred) const -> bool
auto take (size_t n) const -> QueryView
auto skip (size_t n) const -> QueryView

Detailed Description

Lazy, functional-style query/filter view over a snapshot of registered threads.

A QueryView is produced by ThreadRegistry::query() (or by chaining operations on an existing QueryView). It holds an internal std::vector<RegisteredThreadInfo> that is a snapshot – mutations to the originating ThreadRegistry after the QueryView was created are not visible.

Value semantics
QueryView is a regular value type (copyable and movable). All transformation methods (filter, take, skip) return a new QueryView, leaving the original unchanged.
Thread safety
A single QueryView instance is not safe to use concurrently from multiple threads. However, it is safe to create multiple QueryViews concurrently from the same ThreadRegistry, since creation acquires a shared lock on the registry.
API
Provides a functional-style interface:
  • filter(pred) – returns a new QueryView containing only entries that satisfy pred.
  • map(fn) – transforms each entry and returns a std::vector<R>.
  • for_each(fn) – applies fn to every entry.
  • find_if(pred) – returns the first matching entry, or std::nullopt.
  • any / all / none(pred) – boolean aggregation predicates.
  • take(n) / skip(n) – positional slicing, returning new QueryViews.
  • count() / empty() – size queries.
  • entries() – direct access to the underlying vector.

Definition at line 471 of file thread_registry.hpp.

Constructor & Destructor Documentation

◆ QueryView()

threadschedule::ThreadRegistry::QueryView::QueryView ( std::vector< RegisteredThreadInfo > entries)
inlineexplicit

Definition at line 474 of file thread_registry.hpp.

Member Function Documentation

◆ all()

template<typename Predicate>
auto threadschedule::ThreadRegistry::QueryView::all ( Predicate && pred) const -> bool
inlinenodiscard

Definition at line 552 of file thread_registry.hpp.

◆ any()

template<typename Predicate>
auto threadschedule::ThreadRegistry::QueryView::any ( Predicate && pred) const -> bool
inlinenodiscard

Definition at line 541 of file thread_registry.hpp.

◆ count()

auto threadschedule::ThreadRegistry::QueryView::count ( ) const -> size_t
inlinenodiscard

Definition at line 500 of file thread_registry.hpp.

◆ empty()

auto threadschedule::ThreadRegistry::QueryView::empty ( ) const -> bool
inlinenodiscard

Definition at line 505 of file thread_registry.hpp.

◆ entries()

auto threadschedule::ThreadRegistry::QueryView::entries ( ) const -> std::vector<RegisteredThreadInfo> const&
inlinenodiscard

Definition at line 510 of file thread_registry.hpp.

◆ filter()

template<typename Predicate>
auto threadschedule::ThreadRegistry::QueryView::filter ( Predicate && pred) const -> QueryView
inline

Definition at line 479 of file thread_registry.hpp.

◆ find_if()

template<typename Predicate>
auto threadschedule::ThreadRegistry::QueryView::find_if ( Predicate && pred) const -> std::optional<RegisteredThreadInfo>
inlinenodiscard

Definition at line 530 of file thread_registry.hpp.

◆ for_each()

template<typename Fn>
void threadschedule::ThreadRegistry::QueryView::for_each ( Fn && fn) const
inline

Definition at line 492 of file thread_registry.hpp.

◆ map()

template<typename Fn>
auto threadschedule::ThreadRegistry::QueryView::map ( Fn && fn) const -> std::vector<std::invoke_result_t<Fn, RegisteredThreadInfo const&>>
inlinenodiscard

Definition at line 517 of file thread_registry.hpp.

◆ none()

template<typename Predicate>
auto threadschedule::ThreadRegistry::QueryView::none ( Predicate && pred) const -> bool
inlinenodiscard

Definition at line 563 of file thread_registry.hpp.

◆ skip()

auto threadschedule::ThreadRegistry::QueryView::skip ( size_t n) const -> QueryView
inlinenodiscard

Definition at line 576 of file thread_registry.hpp.

◆ take()

auto threadschedule::ThreadRegistry::QueryView::take ( size_t n) const -> QueryView
inlinenodiscard

Definition at line 568 of file thread_registry.hpp.


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