ndmspc  v1.2.0-0.1.rc3
Ndmspc::NGnThreadData Class Reference

Thread-local data object for NDMSPC processing. More...

#include <NGnThreadData.h>

Inheritance diagram for Ndmspc::NGnThreadData:
Ndmspc::NThreadData

Public Member Functions

 NGnThreadData ()
 Constructor.
 
virtual ~NGnThreadData ()
 Destructor.
 
bool Init (size_t id, NGnProcessFuncPtr func, NGnBeginFuncPtr beginFunc, NGnEndFuncPtr endFunc, NGnTree *ngnt, NBinning *binningIn, NGnTree *input=nullptr, const std::string &filename="", const std::string &treename="ngnt")
 Initialize thread data for processing. More...
 
void SetProcessFunc (NGnProcessFuncPtr func)
 Set the processing function pointer. More...
 
bool InitStorage (NStorageTree *ts, const std::string &filename="", const std::string &treename="ngnt")
 Initialize storage tree for thread data. More...
 
NGnTreeGetHnSparseBase () const
 Get pointer to base NGnTree object. More...
 
Long64_t GetNProcessed () const
 Get number of processed entries. More...
 
void SetNProcessed (Long64_t n)
 Set number of processed entries. More...
 
void SetCfg (const json &cfg)
 Set configuration JSON object. More...
 
json GetCfg () const
 Get configuration JSON object. More...
 
void SetResultsFilename (const std::string &filename)
 Set the results filename for TCP mode (shared filesystem path). More...
 
const std::string & GetResultsFilename () const
 Get the results filename for TCP mode. More...
 
bool IsPureCopy () const
 Checks if the object is a pure copy. More...
 
void SetIsPureCopy (bool val)
 Sets the pure copy status of the object. More...
 
virtual void Process (const std::vector< int > &coords)
 Process coordinates (virtual). More...
 
void SetCurrentDefinitionName (const std::string &name)
 
void SyncCurrentDefinitionIds (const std::vector< Long64_t > &ids)
 
void ExecuteBeginFunction ()
 
void ExecuteEndFunction ()
 
void FlushDeferredDeletes ()
 Delete deferred ROOT objects, skipping TCanvas/TPad (leaked safely).
 
virtual Long64_t Merge (TCollection *list)
 Merge thread data from a collection (virtual). More...
 
void SetItemCount (long long itemCount)
 Setters for data members. More...
 
void SetCoordSum (long long coordSum)
 Set the sum of coordinates processed by the thread. More...
 
void SetThreadId (std::thread::id threadId)
 Set the thread's unique identifier. More...
 
void SetIdSet (bool idSet)
 Set whether the thread ID has been assigned. More...
 
void SetAssignedIndex (size_t assignedIndex)
 Set the assigned index for the thread. More...
 
void SetResourceMonitor (NResourceMonitor *monitor)
 Sets the resource monitor for this thread data. More...
 
long long GetItemCount () const
 Getters for data members. More...
 
long long GetCoordSum () const
 Get the sum of coordinates processed by the thread. More...
 
std::thread::id GetThreadId () const
 Get the thread's unique identifier. More...
 
bool GetIdSet () const
 Check if the thread ID has been assigned. More...
 
size_t GetAssignedIndex () const
 Get the assigned index for the thread. More...
 
NResourceMonitorGetResourceMonitor () const
 Gets the resource monitor associated with this thread data. More...
 
virtual void Print (Option_t *option="") const
 Print method override. More...
 

Static Public Attributes

static std::mutex fSharedMutex
 Shared mutex for thread-safe operations.
 

Protected Attributes

NResourceMonitorfResourceMonitor {nullptr}
 Pointer to resource monitor.
 

Private Attributes

NGnProcessFuncPtr fProcessFunc {nullptr}
 Function pointer to the processing function.
 
NGnBeginFuncPtr fBeginFunc {nullptr}
 Function pointer to the begin function.
 
NGnEndFuncPtr fEndFunc {nullptr}
 Function pointer to the end function.
 
NGnTreefHnSparseBase {nullptr}
 Pointer to the base class.
 
Long64_t fNProcessed {0}
 Number of processed entries.
 
NBinningfBiningSource {nullptr}
 Pointer to the source binning (from the original NGnTree)
 
json fCfg {}
 Configuration object.
 
bool fIsPureCopy {false}
 Flag indicating pure copy mode.
 
std::string fResultsFilename {}
 Shared-FS path to copy result to after Close(true) (TCP mode)
 
std::vector< TObject * > fDeferredDeletes
 Objects deferred for single-threaded deletion.
 
long long fItemCount = 0
 Number of items processed.
 
long long fCoordSum = 0
 Sum of coordinates.
 
std::thread::id fThreadId
 Thread ID.
 
bool fIdSet = false
 Flag to indicate if the thread ID is set.
 
size_t fAssignedIndex = 0
 Index assigned to this object.
 

Detailed Description

Thread-local data object for NDMSPC processing.

Manages per-thread processing function, input/output trees, binning, configuration, and processed entry count. Supports initialization, storage setup, processing, and merging.

Author
Martin Vala mvala.nosp@m.@cer.nosp@m.n.ch

Definition at line 19 of file NGnThreadData.h.

Member Function Documentation

◆ GetAssignedIndex()

size_t Ndmspc::NThreadData::GetAssignedIndex ( ) const
inlineinherited

Get the assigned index for the thread.

Returns
Index assigned to the thread.

Definition at line 96 of file NThreadData.h.

References Ndmspc::NThreadData::fAssignedIndex.

Referenced by Ndmspc::NDimensionalExecutor::ExecuteParallel(), FlushDeferredDeletes(), Merge(), and Process().

◆ GetCfg()

json Ndmspc::NGnThreadData::GetCfg ( ) const
inline

Get configuration JSON object.

Returns
JSON configuration.

Definition at line 89 of file NGnThreadData.h.

References fCfg.

◆ GetCoordSum()

long long Ndmspc::NThreadData::GetCoordSum ( ) const
inlineinherited

Get the sum of coordinates processed by the thread.

Returns
Sum of coordinates.

Definition at line 78 of file NThreadData.h.

References Ndmspc::NThreadData::fCoordSum.

◆ GetHnSparseBase()

NGnTree* Ndmspc::NGnThreadData::GetHnSparseBase ( ) const
inline

Get pointer to base NGnTree object.

Returns
Pointer to NGnTree.

Definition at line 65 of file NGnThreadData.h.

References fHnSparseBase.

Referenced by Merge(), and Ndmspc::NGnTree::Process().

◆ GetIdSet()

bool Ndmspc::NThreadData::GetIdSet ( ) const
inlineinherited

Check if the thread ID has been assigned.

Returns
True if ID is set, false otherwise.

Definition at line 90 of file NThreadData.h.

References Ndmspc::NThreadData::fIdSet.

◆ GetItemCount()

long long Ndmspc::NThreadData::GetItemCount ( ) const
inlineinherited

Getters for data members.

Get the number of items processed by the thread.

Returns
Number of items.

Definition at line 72 of file NThreadData.h.

References Ndmspc::NThreadData::fItemCount.

◆ GetNProcessed()

Long64_t Ndmspc::NGnThreadData::GetNProcessed ( ) const
inline

Get number of processed entries.

Returns
Number of processed entries.

Definition at line 71 of file NGnThreadData.h.

References fNProcessed.

Referenced by Merge().

◆ GetResourceMonitor()

NResourceMonitor* Ndmspc::NThreadData::GetResourceMonitor ( ) const
inlineinherited

Gets the resource monitor associated with this thread data.

Returns a pointer to the NResourceMonitor instance currently associated with this thread data. The caller does not take ownership of the returned pointer.

Returns
Pointer to the associated NResourceMonitor instance.

Definition at line 108 of file NThreadData.h.

References Ndmspc::NThreadData::fResourceMonitor.

◆ GetResultsFilename()

const std::string& Ndmspc::NGnThreadData::GetResultsFilename ( ) const
inline

Get the results filename for TCP mode.

Returns
Shared-filesystem path, or empty string if not set.

Definition at line 104 of file NGnThreadData.h.

References fResultsFilename.

Referenced by Merge().

◆ GetThreadId()

std::thread::id Ndmspc::NThreadData::GetThreadId ( ) const
inlineinherited

Get the thread's unique identifier.

Returns
Thread ID.

Definition at line 84 of file NThreadData.h.

References Ndmspc::NThreadData::fThreadId.

◆ Init()

bool Ndmspc::NGnThreadData::Init ( size_t  id,
NGnProcessFuncPtr  func,
NGnBeginFuncPtr  beginFunc,
NGnEndFuncPtr  endFunc,
NGnTree ngnt,
NBinning binningIn,
NGnTree input = nullptr,
const std::string &  filename = "",
const std::string &  treename = "ngnt" 
)

◆ InitStorage()

bool Ndmspc::NGnThreadData::InitStorage ( NStorageTree ts,
const std::string &  filename = "",
const std::string &  treename = "ngnt" 
)

Initialize storage tree for thread data.

Parameters
tsPointer to NStorageTree.
filenameOptional file name.
treenameOptional tree name (default: "ngnt").
Returns
True if storage initialized successfully.

◆ IsPureCopy()

bool Ndmspc::NGnThreadData::IsPureCopy ( ) const
inline

Checks if the object is a pure copy.

Returns
True if the object is a pure copy, false otherwise.

Definition at line 110 of file NGnThreadData.h.

References fIsPureCopy.

◆ Merge()

◆ Print()

void Ndmspc::NThreadData::Print ( Option_t *  option = "") const
virtualinherited

Print method override.

Parameters
optionPrint options.

Definition at line 43 of file NThreadData.cxx.

References Ndmspc::NThreadData::fAssignedIndex, Ndmspc::NThreadData::fCoordSum, Ndmspc::NThreadData::fItemCount, and Ndmspc::NThreadData::fThreadId.

◆ Process()

void Ndmspc::NGnThreadData::Process ( const std::vector< int > &  coords)
virtual

◆ SetAssignedIndex()

void Ndmspc::NThreadData::SetAssignedIndex ( size_t  assignedIndex)
inlineinherited

Set the assigned index for the thread.

Parameters
assignedIndexIndex assigned to the thread.

Definition at line 53 of file NThreadData.h.

References Ndmspc::NThreadData::fAssignedIndex.

Referenced by Init().

◆ SetCfg()

void Ndmspc::NGnThreadData::SetCfg ( const json &  cfg)
inline

Set configuration JSON object.

Parameters
cfgJSON configuration.

Definition at line 83 of file NGnThreadData.h.

References fCfg.

Referenced by Ndmspc::NGnTree::Process().

◆ SetCoordSum()

void Ndmspc::NThreadData::SetCoordSum ( long long  coordSum)
inlineinherited

Set the sum of coordinates processed by the thread.

Parameters
coordSumSum of coordinates.

Definition at line 35 of file NThreadData.h.

References Ndmspc::NThreadData::fCoordSum.

◆ SetIdSet()

void Ndmspc::NThreadData::SetIdSet ( bool  idSet)
inlineinherited

Set whether the thread ID has been assigned.

Parameters
idSetTrue if ID is set, false otherwise.

Definition at line 47 of file NThreadData.h.

References Ndmspc::NThreadData::fIdSet.

◆ SetIsPureCopy()

void Ndmspc::NGnThreadData::SetIsPureCopy ( bool  val)
inline

Sets the pure copy status of the object.

Parameters
valBoolean value to set the pure copy status.

Definition at line 116 of file NGnThreadData.h.

References fIsPureCopy.

◆ SetItemCount()

void Ndmspc::NThreadData::SetItemCount ( long long  itemCount)
inlineinherited

Setters for data members.

Set the number of items processed by the thread.

Parameters
itemCountNumber of items.

Definition at line 29 of file NThreadData.h.

References Ndmspc::NThreadData::fItemCount.

◆ SetNProcessed()

void Ndmspc::NGnThreadData::SetNProcessed ( Long64_t  n)
inline

Set number of processed entries.

Parameters
nNumber of processed entries.

Definition at line 77 of file NGnThreadData.h.

References fNProcessed.

◆ SetProcessFunc()

void Ndmspc::NGnThreadData::SetProcessFunc ( NGnProcessFuncPtr  func)
inline

Set the processing function pointer.

Parameters
funcFunction pointer to set.

Definition at line 50 of file NGnThreadData.h.

References fProcessFunc.

◆ SetResourceMonitor()

void Ndmspc::NThreadData::SetResourceMonitor ( NResourceMonitor monitor)
inlineinherited

Sets the resource monitor for this thread data.

This function assigns the given NResourceMonitor pointer to the internal resource monitor member. Ownership of the pointer is not transferred; the caller is responsible for managing the lifetime of the monitor object.

Parameters
monitorPointer to an NResourceMonitor instance to be associated with this thread data.

Definition at line 64 of file NThreadData.h.

References Ndmspc::NThreadData::fResourceMonitor.

◆ SetResultsFilename()

void Ndmspc::NGnThreadData::SetResultsFilename ( const std::string &  filename)
inline

Set the results filename for TCP mode (shared filesystem path).

When set, TaskLoop will copy the locally-written file to this path after Close(true) before sending DONE to the supervisor.

Parameters
filenameShared-filesystem path where results should be deposited.

Definition at line 98 of file NGnThreadData.h.

References fResultsFilename.

Referenced by Ndmspc::NGnTree::Process().

◆ SetThreadId()

void Ndmspc::NThreadData::SetThreadId ( std::thread::id  threadId)
inlineinherited

Set the thread's unique identifier.

Parameters
threadIdThread ID.

Definition at line 41 of file NThreadData.h.

References Ndmspc::NThreadData::fThreadId.

Referenced by Init().


The documentation for this class was generated from the following files: