17#if !THREADMAN_WITH_NLOHMANN_JSON
18#error "threadman/parcel.hpp requires THREADMAN_WITH_NLOHMANN_JSON to be enabled \
19(parcel pulls in nlohmann/json — the threadman cell adapters rely on the JSON-gated \
20to_json/from_json overloads of the snapshot types)."
26#include <parcel/parcel.h>
36 using base_t = parcel::BaseCell<ThreadSnapshotCell, ThreadSnapshot>;
40 using base_t::operator=;
41 static constexpr std::string_view
kind_id =
"tm:thread_snapshot";
43 [[nodiscard]] std::string
to_string()
const override {
44 std::ostringstream os;
45 os << this->value.name <<
"#" << this->value.id;
49 [[maybe_unused]]
static parcel::cell_t
from_json(parcel::json_t
const& j,
50 parcel::ParcelRegistry
const&) {
51 return base_t::from_json_strict(j);
56 std::make_shared<parcel::SimpleCellTypeDescriptor<ThreadSnapshotCell>>(
58 .name =
"ThreadSnapshot",
59 .description =
"Snapshot of a ManagedThread.",
66 using base_t = parcel::BaseCell<ThreadPoolStatsCell, ThreadPoolStats>;
70 using base_t::operator=;
71 static constexpr std::string_view
kind_id =
"tm:thread_pool_stats";
73 [[nodiscard]] std::string
to_string()
const override {
74 std::ostringstream os;
75 os << this->value.name <<
"#" << this->value.pool_id;
79 [[maybe_unused]]
static parcel::cell_t
from_json(parcel::json_t
const& j,
80 parcel::ParcelRegistry
const&) {
81 return base_t::from_json_strict(j);
86 std::make_shared<parcel::SimpleCellTypeDescriptor<ThreadPoolStatsCell>>(
88 .name =
"ThreadPoolStats",
89 .description =
"Headline counters and state of a ThreadPool.",
96 using base_t = parcel::BaseCell<TaskSnapshotCell, TaskSnapshot>;
100 using base_t::operator=;
101 static constexpr std::string_view
kind_id =
"tm:task_snapshot";
104 std::ostringstream os;
105 os <<
"task#" << this->value.id;
109 [[maybe_unused]]
static parcel::cell_t
from_json(parcel::json_t
const& j,
110 parcel::ParcelRegistry
const&) {
111 return base_t::from_json_strict(j);
115 static const auto d = std::make_shared<parcel::SimpleCellTypeDescriptor<TaskSnapshotCell>>(
117 .name =
"TaskSnapshot",
118 .description =
"Snapshot of a single submitted task.",
125 using base_t = parcel::BaseCell<FutureSnapshotCell, FutureSnapshot>;
128 using base_t::base_t;
129 using base_t::operator=;
130 static constexpr std::string_view
kind_id =
"tm:future_snapshot";
133 return this->value.ready ?
"future:ready" :
"future:pending";
136 [[maybe_unused]]
static parcel::cell_t
from_json(parcel::json_t
const& j,
137 parcel::ParcelRegistry
const&) {
138 return base_t::from_json_strict(j);
142 static const auto d =
143 std::make_shared<parcel::SimpleCellTypeDescriptor<FutureSnapshotCell>>(
145 .name =
"FutureSnapshot",
146 .description =
"Snapshot of a Future/SharedFuture state.",
153 using base_t = parcel::BaseCell<ManagerSummaryCell, ManagerSummary>;
156 using base_t::base_t;
157 using base_t::operator=;
158 static constexpr std::string_view
kind_id =
"tm:manager_summary";
161 std::ostringstream os;
162 os <<
"summary{pools=" << this->value.total_pools
163 <<
", workers=" << this->value.total_live_workers
164 <<
", queued=" << this->value.total_queued <<
"}";
168 [[maybe_unused]]
static parcel::cell_t
from_json(parcel::json_t
const& j,
169 parcel::ParcelRegistry
const&) {
170 return base_t::from_json_strict(j);
174 static const auto d =
175 std::make_shared<parcel::SimpleCellTypeDescriptor<ManagerSummaryCell>>(
177 .name =
"ManagerSummary",
178 .description =
"Aggregate periodic snapshot of the ThreadManager world.",
200#define THREADMAN_HAS_PARCEL 1
Definition parcel.hpp:124
static parcel::cell_type_descriptor_t descriptor()
Definition parcel.hpp:141
static parcel::cell_t from_json(parcel::json_t const &j, parcel::ParcelRegistry const &)
Definition parcel.hpp:136
static constexpr std::string_view kind_id
Definition parcel.hpp:130
std::string to_string() const override
Definition parcel.hpp:132
Definition parcel.hpp:152
static constexpr std::string_view kind_id
Definition parcel.hpp:158
std::string to_string() const override
Definition parcel.hpp:160
static parcel::cell_type_descriptor_t descriptor()
Definition parcel.hpp:173
static parcel::cell_t from_json(parcel::json_t const &j, parcel::ParcelRegistry const &)
Definition parcel.hpp:168
std::string to_string() const override
Definition parcel.hpp:103
static parcel::cell_type_descriptor_t descriptor()
Definition parcel.hpp:114
static constexpr std::string_view kind_id
Definition parcel.hpp:101
static parcel::cell_t from_json(parcel::json_t const &j, parcel::ParcelRegistry const &)
Definition parcel.hpp:109
static parcel::cell_type_descriptor_t descriptor()
Definition parcel.hpp:84
static constexpr std::string_view kind_id
Definition parcel.hpp:71
static parcel::cell_t from_json(parcel::json_t const &j, parcel::ParcelRegistry const &)
Definition parcel.hpp:79
std::string to_string() const override
Definition parcel.hpp:73
static constexpr std::string_view kind_id
Definition parcel.hpp:41
std::string to_string() const override
Definition parcel.hpp:43
static parcel::cell_type_descriptor_t descriptor()
Definition parcel.hpp:54
static parcel::cell_t from_json(parcel::json_t const &j, parcel::ParcelRegistry const &)
Definition parcel.hpp:49
Central feature-gate header for ThreadMan's optional integrations and tunable defaults.
nlohmann/json serialization hooks for the snapshot value-types and their enums.
Definition exceptions.hpp:22
void register_cells(parcel::ParcelRegistry ®istry)
Definition parcel.hpp:184
PARCEL_DEFAULT_CELL(threadman::ThreadSnapshotCell)
Plain value snapshots of the live state of the ThreadMan world — threads, pools, tasks,...