atomic
This commit is contained in:
parent
ff46bdb17a
commit
4c401c39fb
|
@ -99,12 +99,12 @@ void dmSendMonitorReport() {
|
|||
if (!tsEnableMonitor || tsMonitorFqdn[0] == 0 || tsMonitorPort == 0) return;
|
||||
dTrace("send monitor report to %s:%u", tsMonitorFqdn, tsMonitorPort);
|
||||
|
||||
SDnode *pDnode = dmInstance();
|
||||
dmGetDmMonitorInfo(pDnode);
|
||||
dmGetMmMonitorInfo(pDnode);
|
||||
dmGetVmMonitorInfo(pDnode);
|
||||
dmGetQmMonitorInfo(pDnode);
|
||||
dmGetSmMonitorInfo(pDnode);
|
||||
//SDnode *pDnode = dmInstance();
|
||||
//dmGetDmMonitorInfo(pDnode);
|
||||
//dmGetMmMonitorInfo(pDnode);
|
||||
//dmGetVmMonitorInfo(pDnode);
|
||||
//dmGetQmMonitorInfo(pDnode);
|
||||
//dmGetSmMonitorInfo(pDnode);
|
||||
//monSendReport();
|
||||
|
||||
monSendPromReport();
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
struct taos_metric_sample {
|
||||
taos_metric_type_t type; /**< type is the metric type for the sample */
|
||||
char *l_value; /**< l_value is the full metric name and label set represeted as a string */
|
||||
_Atomic double r_value; /**< r_value is the value of the metric sample */
|
||||
/*_Atomic*/ int64_t r_value; /**< r_value is the value of the metric sample */
|
||||
};
|
||||
|
||||
#endif // TAOS_METRIC_SAMPLE_T_H
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
// Public
|
||||
#include "taos_alloc.h"
|
||||
|
|
|
@ -171,7 +171,7 @@ int taos_metric_formatter_load_sample(taos_metric_formatter_t *self, taos_metric
|
|||
if (r) return r;
|
||||
|
||||
char buffer[50];
|
||||
sprintf(buffer, "%.17g", sample->r_value);
|
||||
sprintf(buffer, "%ld", sample->r_value);
|
||||
r = taos_string_builder_add_str(self->string_builder, buffer);
|
||||
if (r) return r;
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "taos_log.h"
|
||||
#include "taos_metric_sample_i.h"
|
||||
#include "taos_metric_sample_t.h"
|
||||
#include "osAtomic.h"
|
||||
|
||||
taos_metric_sample_t *taos_metric_sample_new(taos_metric_type_t type, const char *l_value, double r_value) {
|
||||
taos_metric_sample_t *self = (taos_metric_sample_t *)taos_malloc(sizeof(taos_metric_sample_t));
|
||||
|
@ -62,13 +63,18 @@ int taos_metric_sample_add(taos_metric_sample_t *self, double r_value) {
|
|||
if (r_value < 0) {
|
||||
return 1;
|
||||
}
|
||||
/*
|
||||
_Atomic double old = atomic_load(&self->r_value);
|
||||
|
||||
for (;;) {
|
||||
_Atomic double new = ATOMIC_VAR_INIT(old + r_value);
|
||||
if (atomic_compare_exchange_weak(&self->r_value, &old, new)) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
*/
|
||||
atomic_fetch_add_64(&self->r_value, r_value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int taos_metric_sample_sub(taos_metric_sample_t *self, double r_value) {
|
||||
|
@ -77,6 +83,7 @@ int taos_metric_sample_sub(taos_metric_sample_t *self, double r_value) {
|
|||
TAOS_LOG(TAOS_METRIC_INCORRECT_TYPE);
|
||||
return 1;
|
||||
}
|
||||
/*
|
||||
_Atomic double old = atomic_load(&self->r_value);
|
||||
for (;;) {
|
||||
_Atomic double new = ATOMIC_VAR_INIT(old - r_value);
|
||||
|
@ -84,6 +91,9 @@ int taos_metric_sample_sub(taos_metric_sample_t *self, double r_value) {
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
*/
|
||||
atomic_fetch_sub_64(&self->r_value, r_value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int taos_metric_sample_set(taos_metric_sample_t *self, double r_value) {
|
||||
|
@ -91,6 +101,9 @@ int taos_metric_sample_set(taos_metric_sample_t *self, double r_value) {
|
|||
TAOS_LOG(TAOS_METRIC_INCORRECT_TYPE);
|
||||
return 1;
|
||||
}
|
||||
/*
|
||||
atomic_store(&self->r_value, r_value);
|
||||
*/
|
||||
atomic_store_64(&self->r_value, r_value);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue