Project
Loading...
Searching...
No Matches
DeviceState.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11#ifndef O2_FRAMEWORK_DEVICESTATE_H_
12#define O2_FRAMEWORK_DEVICESTATE_H_
13
17
18#include <vector>
19#include <string>
20#include <atomic>
21
22typedef struct uv_loop_s uv_loop_t;
23typedef struct uv_timer_s uv_timer_t;
24typedef struct uv_poll_s uv_poll_t;
25typedef struct uv_signal_s uv_signal_t;
26typedef struct uv_async_s uv_async_t;
27
28namespace o2::framework
29{
30
31struct DataProcessorContext;
32
36 enum LoopReason : int {
37 NO_REASON = 0, // No tracked reason to wake up
38 METRICS_MUST_FLUSH = 1, // Metrics available to flush
39 SIGNAL_ARRIVED = 1 << 1, // Signal has arrived
40 DATA_SOCKET_POLLED = 1 << 2, // Data has arrived
41 DATA_INCOMING = 1 << 3, // Data was read
42 DATA_OUTGOING = 1 << 4, // Data was written
43 WS_COMMUNICATION = 1 << 5, // Communication over WS
44 TIMER_EXPIRED = 1 << 6, // Timer expired
45 WS_CONNECTED = 1 << 7, // Connection to driver established
46 WS_CLOSING = 1 << 8, // Events related to WS shutting down
47 WS_READING = 1 << 9, // Events related to WS shutting down
48 WS_WRITING = 1 << 10, // Events related to WS shutting down
49 ASYNC_NOTIFICATION = 1 << 11, // Some other thread asked the main one to wake up
50 OOB_ACTIVITY = 1 << 12, // Out of band activity
51 UNKNOWN = 1 << 13, // Unknown reason why we are here.
52 FIRST_LOOP = 1 << 14, // First loop to be executed
53 NEW_STATE_PENDING = 1 << 15, // Someone invoked NewStatePending
54 PREVIOUSLY_ACTIVE = 1 << 16, // The previous loop was active
55 TRACE_CALLBACKS = 1 << 17, // Trace callbacks
56 TRACE_USERCODE = 1 << 18, // Trace only usercode
57 DATA_CONNECTED = 1 << 19, // Data channel connected
58 };
59
60 enum LogStreams : int {
61 NO_LOG = 0,
62 DEVICE_LOG = 1 << 0, // Log for Data Processing Device activities.
63 COMPLETION_LOG = 1 << 1, // Log for the completion policy of the device.
64 MONITORING_SERVICE_LOG = 1 << 2, // Log for the monitoring service flushing.
65 DATA_PROCESSOR_CONTEXT_LOG = 1 << 3, // Log for the DataProcessorContext callbacks
66 STREAM_CONTEXT_LOG = 1 << 4, // Log for the StreamContext callbacks
67 };
68
69 enum ProcessingType : int {
70 Any, // Any kind of processing is allowed
71 CalibrationOnly, // Only calibrations are allowed to be processed / produced
72 };
73
74 std::vector<InputChannelInfo> inputChannelInfos;
76 // What kind of processing is allowed. By default we allow any.
77 // If we are past the data processing timeout, this will be
78 // CalibrationOnly. We need to reset it at every start.
80
81 bool quitRequested = false;
82 std::atomic<int64_t> cleanupCount = -1;
83
86 std::vector<ComputingQuotaOffer> pendingOffers;
89 std::vector<ComputingQuotaConsumer> offerConsumers;
90
91 // The libuv event loop which serves this device.
92 uv_loop_t* loop = nullptr;
93 // The list of active timers which notify this device.
94 std::vector<uv_timer_t*> activeTimers;
95 // The list of timers fired in this loop
96 std::vector<uv_timer_t*> firedTimers;
97 // The list of pollers for active input channels
98 std::vector<uv_poll_t*> activeInputPollers;
99 // The list of pollers for active output channels
100 std::vector<uv_poll_t*> activeOutputPollers;
102 std::vector<uv_signal_t*> activeSignals;
104 std::vector<uv_poll_t*> activeOutOfBandPollers;
105
107
108 // A list of states which we should go to
109 std::vector<std::string> nextFairMQState;
110
112 int loopReason = 0;
116 int logStreams = 0;
119 std::vector<int> severityStack;
121
122 // The DataProcessorContext which was most recently active.
123 // We use this to determine if we should trigger the loop without
124 // waiting for some events.
125 std::atomic<DataProcessorContext*> lastActiveDataProcessor = nullptr;
126};
127
128} // namespace o2::framework
129#endif // O2_FRAMEWORK_DEVICESTATE_H_
struct uv_timer_s uv_timer_t
struct uv_signal_s uv_signal_t
struct uv_async_s uv_async_t
struct uv_poll_s uv_poll_t
struct uv_loop_s uv_loop_t
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
@ Streaming
Data is being processed.
@ NoTransition
No pending transitions.
Running state information of a given device.
Definition DeviceState.h:34
std::vector< ComputingQuotaOffer > pendingOffers
Definition DeviceState.h:86
std::vector< std::string > nextFairMQState
std::vector< int > severityStack
int tracingFlags
Bitmask of LoopReason to trace.
int loopReason
Bitmask of LoopReason which caused this iterations.
std::vector< uv_timer_t * > activeTimers
Definition DeviceState.h:94
LoopReason
Motivation for the loop being triggered.
Definition DeviceState.h:36
std::atomic< int64_t > cleanupCount
Definition DeviceState.h:82
std::vector< uv_poll_t * > activeOutputPollers
std::vector< uv_signal_t * > activeSignals
The list of active signal handlers.
ProcessingType allowedProcessing
Definition DeviceState.h:79
TransitionHandlingState transitionHandling
std::atomic< DataProcessorContext * > lastActiveDataProcessor
std::vector< ComputingQuotaConsumer > offerConsumers
Definition DeviceState.h:89
std::vector< uv_poll_t * > activeInputPollers
Definition DeviceState.h:98
std::vector< uv_poll_t * > activeOutOfBandPollers
The list for active out-of-bound pollers.
std::vector< InputChannelInfo > inputChannelInfos
Definition DeviceState.h:74
int logStreams
Bitmask of log streams which are available.
std::vector< uv_timer_t * > firedTimers
Definition DeviceState.h:96