ndmspc v1.2.0-0.1.rc7
Loading...
Searching...
No Matches
NThreadData.h
1#ifndef Ndmspc_NThreadData_H
2#define Ndmspc_NThreadData_H
3#include <vector>
4#include <thread>
5#include <cstddef>
6#include <mutex>
7#include <TObject.h>
8#include "NResourceMonitor.h"
9
10namespace Ndmspc {
11
21class NThreadData : public TObject {
22 public:
24
29 void SetItemCount(long long itemCount) { fItemCount = itemCount; }
30
35 void SetCoordSum(long long coordSum) { fCoordSum = coordSum; }
36
41 void SetThreadId(std::thread::id threadId) { fThreadId = threadId; }
42
47 void SetIdSet(bool idSet) { fIdSet = idSet; }
48
53 void SetAssignedIndex(size_t assignedIndex) { fAssignedIndex = assignedIndex; }
54
65
67
72 long long GetItemCount() const { return fItemCount; }
73
78 long long GetCoordSum() const { return fCoordSum; }
79
84 std::thread::id GetThreadId() const { return fThreadId; }
85
90 bool GetIdSet() const { return fIdSet; }
91
96 size_t GetAssignedIndex() const { return fAssignedIndex; }
98 static std::mutex fSharedMutex;
99
109
113 NThreadData();
114
118 virtual ~NThreadData();
119
124 virtual void Process(const std::vector<int> & coords);
125
130 virtual void Print(Option_t * option = "") const;
131
132 protected:
134
135 private:
136 long long fItemCount = 0;
137 long long fCoordSum = 0;
138 std::thread::id fThreadId;
139 bool fIdSet = false;
140 size_t fAssignedIndex = 0;
141
143 ClassDef(NThreadData, 1);
145};
146} // namespace Ndmspc
147#endif
Monitors and records resource usage (CPU, memory, wall time) for processes or threads.
void SetItemCount(long long itemCount)
Setters for data members.
Definition NThreadData.h:29
void SetResourceMonitor(NResourceMonitor *monitor)
Sets the resource monitor for this thread data.
Definition NThreadData.h:64
bool fIdSet
Flag to indicate if the thread ID is set.
long long GetCoordSum() const
Get the sum of coordinates processed by the thread.
Definition NThreadData.h:78
size_t fAssignedIndex
Index assigned to this object.
virtual ~NThreadData()
Virtual destructor.
long long fCoordSum
Sum of coordinates.
long long GetItemCount() const
Getters for data members.
Definition NThreadData.h:72
virtual void Print(Option_t *option="") const
Print method override.
size_t GetAssignedIndex() const
Get the assigned index for the thread.
Definition NThreadData.h:96
std::thread::id fThreadId
Thread ID.
std::thread::id GetThreadId() const
Get the thread's unique identifier.
Definition NThreadData.h:84
virtual void Process(const std::vector< int > &coords)
Process method for thread data.
void SetAssignedIndex(size_t assignedIndex)
Set the assigned index for the thread.
Definition NThreadData.h:53
NResourceMonitor * fResourceMonitor
Pointer to resource monitor.
NThreadData()
Default constructor.
long long fItemCount
Number of items processed.
void SetCoordSum(long long coordSum)
Set the sum of coordinates processed by the thread.
Definition NThreadData.h:35
void SetThreadId(std::thread::id threadId)
Set the thread's unique identifier.
Definition NThreadData.h:41
void SetIdSet(bool idSet)
Set whether the thread ID has been assigned.
Definition NThreadData.h:47
NResourceMonitor * GetResourceMonitor() const
Gets the resource monitor associated with this thread data.
bool GetIdSet() const
Check if the thread ID has been assigned.
Definition NThreadData.h:90
static std::mutex fSharedMutex
Shared mutex for thread-safe operations.
Definition NThreadData.h:98
Global callback function for libwebsockets client events.