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 <optional>
9#include <variant>
10
11#include "GaudiKernel/StatusCode.h"
15
26
31
32 // Wire message consists of a header and an optional body.
33 // If message type is Data, FinalWorkerStatus or WorkerError, payload
34 // in header indicates tag used to send body.
35 // message type, source, int payload
36 using WireMsgHdr = std::array<int, 3>; // three ints for the three components of the header
37 using WireMsgBody = std::array<int, 10>; // 320 bit max body length (for a DataDescr)
38 using WireMsg = std::tuple<WireMsgHdr, std::optional<WireMsgBody>>;
39
40 int source = -1; // Filled in when it is sent
41 ClusterMessageType messageType{ClusterMessageType::EMPTY};
42
43 struct WorkerStatus {
44 StatusCode status{};
48 };
49
50 struct DataDescr {
51 void* ptr = nullptr;
52 std::size_t len = 0;
53 std::size_t align = 0;
54
55 bool received = false; // set if this DataDescr was received and therefore
56 // owns its memory
57 std::size_t evtNumber = 0;
58 std::size_t fileNumber = 0;
59
60 template <typename T>
61 DataDescr(const T* ptr, std::size_t count = 1)
62 : ptr((void*)ptr), len(count * sizeof(T)), align(alignof(T)) {}
63
64 DataDescr(DataDescr&& rhs) noexcept;
65
66 DataDescr(const DataDescr&) = delete;
67 DataDescr& operator=(const DataDescr&) = delete;
68
69 DataDescr(const WireMsgBody& body);
70
71 DataDescr& operator=(DataDescr&& rhs) noexcept;
72
73 ~DataDescr();
74 };
75
76 // A payload is used with:
77 // ProvideEvent: an int indicating the event index
78 // ProvideStatus and WorkerError: a WorkerStatus
79 // Data: DataDescr for miscellaneous data (variable size)
80 using Payload_t = std::variant<std::monostate, int, WorkerStatus, DataDescr>;
82
84
86
88
90
92
93 ClusterMessage(const WireMsg&);
94
95 [[nodiscard]] WireMsg wire_msg() const;
96};
97
98#include "ClusterMessage.icc"
99#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:146
DataDescr(const T *ptr, std::size_t count=1)
DataDescr & operator=(const DataDescr &)=delete
DataDescr(const DataDescr &)=delete
ClusterMessageType messageType
Payload_t payload
std::array< int, 10 > WireMsgBody
std::tuple< WireMsgHdr, std::optional< WireMsgBody > > WireMsg
WireMsg wire_msg() const
std::array< int, 3 > WireMsgHdr
std::variant< std::monostate, int, WorkerStatus, DataDescr > Payload_t