ATLAS Offline Software
Loading...
Searching...
No Matches
ClusterMessage.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4#ifndef ATHENAKERNEL_CLUSTERMESSAGE_H
5#define ATHENAKERNEL_CLUSTERMESSAGE_H
6
7#include <array>
8#include <cstdint>
9#include <optional>
10#include <variant>
11
12#include "GaudiKernel/StatusCode.h"
16
27
32
33 // Wire message consists of a header and an optional body.
34 // If message type is Data, FinalWorkerStatus or WorkerError, payload
35 // in header indicates tag used to send body.
36 // message type, source, int payload
37 using WireMsgHdr = std::array<std::uint32_t, 3>; // three ints for the three
38 // components of the header
39 using WireMsgBody = std::array<std::uint32_t, 10>; // 320 bit max body length
40 // (for a DataDescr)
41 using WireMsg = std::tuple<WireMsgHdr, std::optional<WireMsgBody>>;
42
43 int source = -1; // Filled in when it is sent
44 ClusterMessageType messageType{ClusterMessageType::EMPTY};
45
46 struct WorkerStatus {
47 StatusCode status{};
51 };
52
53 struct DataDescr {
54 void* ptr = nullptr;
55 std::size_t len = 0;
56 std::size_t align = 0;
57
58 bool received = false; // set if this DataDescr was received and therefore
59 // owns its memory
60 std::size_t evtNumber = 0;
61 std::size_t fileNumber = 0;
62
63 template <typename T>
64 DataDescr(const T* ptr, std::size_t count = 1)
65 : ptr((void*)ptr), len(count * sizeof(T)), align(alignof(T)) {}
66
67 DataDescr(DataDescr&& rhs) noexcept;
68
69 DataDescr(const DataDescr&) = delete;
70 DataDescr& operator=(const DataDescr&) = delete;
71
72 DataDescr(const WireMsgBody& body);
73
74 DataDescr& operator=(DataDescr&& rhs) noexcept;
75
76 ~DataDescr();
77 };
78
79 // A payload is used with:
80 // ProvideEvent: an int indicating the event index
81 // ProvideStatus and WorkerError: a WorkerStatus
82 // Data: DataDescr for miscellaneous data (variable size)
83 using Payload_t = std::variant<std::monostate, int, WorkerStatus, DataDescr>;
85
87
89
91
93
95
96 ClusterMessage(const WireMsg&);
97
98 [[nodiscard]] WireMsg wire_msg() const;
99};
100
101#include "ClusterMessage.icc"
102#endif // ATHENAKERNEL_CLUSTERMESSAGE_H
@ Data
Definition BaseObject.h:11
ClusterMessageType
An enum class defining what type of message this is.
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:148
DataDescr(const T *ptr, std::size_t count=1)
DataDescr & operator=(const DataDescr &)=delete
DataDescr(const DataDescr &)=delete
ClusterMessageType messageType
Payload_t payload
std::tuple< WireMsgHdr, std::optional< WireMsgBody > > WireMsg
std::array< std::uint32_t, 3 > WireMsgHdr
WireMsg wire_msg() const
std::array< std::uint32_t, 10 > WireMsgBody
std::variant< std::monostate, int, WorkerStatus, DataDescr > Payload_t