TEC
A lightweight C++ library enabling safe, efficient execution in multithreaded and concurrent systems.
Loading...
Searching...
No Matches
tec_message.hpp
Go to the documentation of this file.
1// Time-stamp: <Last changed 2026-02-20 15:59:45 by magnolia>
2/*----------------------------------------------------------------------
3------------------------------------------------------------------------
4Copyright (c) 2020-2026 The Emacs Cat (https://github.com/olddeuteronomy/tec).
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17------------------------------------------------------------------------
18----------------------------------------------------------------------*/
26#pragma once
27
28#include <any>
29
30#include "tec/tec_def.hpp" // IWYU pragma: keep
31#include "tec/tec_status.hpp"
32#include "tec/tec_signal.hpp"
33
34
35namespace tec {
36
43using Message = std::any;
44
49using Request = std::any;
50
55using Reply = std::any;
56
60
67inline Message nullmsg() noexcept { return Message{}; }
68
75inline bool is_null(const Message& msg) noexcept { return !msg.has_value(); }
76
84inline auto name(const Message& msg) noexcept { return msg.type().name(); }
85
89struct Payload {
90 Signal* ready;
91 Status* status;
92 Request request;
93 Reply reply;
94};
95
97
98} // namespace tec
A thread-safe signal mechanism for inter-thread synchronization.
Definition tec_signal.hpp:44
A message used for RPC-style calls.
Definition tec_message.hpp:89
Common definitions and utilities for the tec namespace.
Message nullmsg() noexcept
Creates a null message.
Definition tec_message.hpp:67
bool is_null(const Message &msg) noexcept
Checks if a message is null.
Definition tec_message.hpp:75
std::any Reply
Type alias for a reply object that can hold any object.
Definition tec_message.hpp:55
std::any Message
Type alias for a message that can hold any object.
Definition tec_message.hpp:43
std::any Request
Type alias for a request object that can hold any object.
Definition tec_message.hpp:49
auto name(const Message &msg) noexcept
Retrieves the type name of a message's content for registering the corresponding message handler.
Definition tec_message.hpp:84
Defines a thread-safe signal implementation using mutex and condition variable.
Defines error handling types and utilities for the tec namespace.