N|Solid
Classes | Public Types | Public Member Functions | List of all members
node::nsolid::ThreadMetrics Class Reference

Class that allows to retrieve thread-specific metrics from a process. More...

#include <nsolid.h>

Classes

struct  MetricsStor
 POD type to store thread metrics data. More...
 

Public Types

using thread_metrics_proxy_sig = void(*)(ThreadMetrics *)
 

Public Member Functions

 ThreadMetrics (uint64_t thread_id)
 Construct a new Thread Metrics object. More...
 
 ~ThreadMetrics ()
 Destroy the Thread Metrics object. More...
 
std::string toJSON ()
 Returns the current N|Solid JS thread metrics in JSON format. More...
 
int Get (MetricsStor *stor)
 It retrieves the current N|Solid JS thread metrics. A previous call to Update() is needed. More...
 
template<typename Cb , typename... Data>
int Update (Cb &&cb, Data &&... data)
 Calculates and stores the N|Solid JS thread metrics. A callback is called when the retrieval has completed. More...
 

Detailed Description

Class that allows to retrieve thread-specific metrics from a process.

Constructor & Destructor Documentation

◆ ThreadMetrics()

node::nsolid::ThreadMetrics::ThreadMetrics ( uint64_t  thread_id)
explicit

Construct a new Thread Metrics object.

Parameters
thread_idthe id of the JS thread the metrics are going to be retrieved from.

◆ ~ThreadMetrics()

node::nsolid::ThreadMetrics::~ThreadMetrics ( )

Destroy the Thread Metrics object.

Member Function Documentation

◆ Get()

int node::nsolid::ThreadMetrics::Get ( MetricsStor stor)

It retrieves the current N|Solid JS thread metrics. A previous call to Update() is needed.

Parameters
storA MetricsStor object where the actual metrics will be written to.
Returns
NSOLID_E_SUCCESS in case of success or a different NSOLID_E_ error value otherwise.

◆ toJSON()

std::string node::nsolid::ThreadMetrics::toJSON ( )

Returns the current N|Solid JS thread metrics in JSON format.

Returns
std::string

◆ Update()

template<typename Cb , typename... Data>
int node::nsolid::ThreadMetrics::Update ( Cb &&  cb,
Data &&...  data 
)

Calculates and stores the N|Solid JS thread metrics. A callback is called when the retrieval has completed.

Parameters
cbcallback function with the following signature void(*)(ThreadMetrics*, ...Data)
datavariable number of arguments to be propagated to the callback.
Returns
NSOLID_E_SUCCESS in case of success or a different NSOLID_E_ error value otherwise.

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