mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-25 11:00:35 +00:00
core: use seastar shared ptr in scollectd
This commit is contained in:
@@ -60,17 +60,15 @@ class impl {
|
||||
double _avg = 0;
|
||||
|
||||
public:
|
||||
// Note: we use std::shared_ptr, not the C* one. This is because currently
|
||||
// seastar sp does not handle polymorphism. And we use it.
|
||||
typedef std::map<type_instance_id, std::shared_ptr<value_list> > value_list_map;
|
||||
typedef std::map<type_instance_id, shared_ptr<value_list> > value_list_map;
|
||||
typedef value_list_map::value_type value_list_pair;
|
||||
|
||||
void add_polled(const type_instance_id & id,
|
||||
const std::shared_ptr<value_list> & values) {
|
||||
const shared_ptr<value_list> & values) {
|
||||
_values.insert(std::make_pair(id, values));
|
||||
}
|
||||
void remove_polled(const type_instance_id & id) {
|
||||
_values.insert(std::make_pair(id, std::shared_ptr<value_list>()));
|
||||
_values.insert(std::make_pair(id, shared_ptr<value_list>()));
|
||||
}
|
||||
// explicitly send a type_instance value list (outside polling)
|
||||
future<> send_metric(const type_instance_id & id,
|
||||
@@ -381,7 +379,7 @@ impl & get_impl() {
|
||||
}
|
||||
|
||||
void add_polled(const type_instance_id & id,
|
||||
const std::shared_ptr<value_list> & values) {
|
||||
const shared_ptr<value_list> & values) {
|
||||
get_impl().add_polled(id, values);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
#include "future.hh"
|
||||
#include "net/byteorder.hh"
|
||||
#include "core/shared_ptr.hh"
|
||||
|
||||
/**
|
||||
* Implementation of rudimentary collectd data gathering.
|
||||
@@ -355,7 +356,7 @@ private:
|
||||
std::tuple < Args... > _values;
|
||||
};
|
||||
|
||||
void add_polled(const type_instance_id &, const std::shared_ptr<value_list> &);
|
||||
void add_polled(const type_instance_id &, const shared_ptr<value_list> &);
|
||||
|
||||
typedef std::function<void()> notify_function;
|
||||
template<typename... _Args>
|
||||
@@ -393,7 +394,7 @@ static type_instance_id add_polled_metric(const type_instance_id & id,
|
||||
_Args&& ... args) {
|
||||
typedef decltype(make_type_instance(std::forward<_Args>(args)...)) impl_type;
|
||||
add_polled(id,
|
||||
std::make_shared<impl_type>(
|
||||
::make_shared<impl_type>(
|
||||
make_type_instance(std::forward<_Args>(args)...)));
|
||||
return id;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user