Skip to content

Commit 42f02b4

Browse files
Make function definitions inline
1 parent 7b9ac5f commit 42f02b4

File tree

2 files changed

+25
-25
lines changed

2 files changed

+25
-25
lines changed

include/cpp-statsd-client/StatsdClient.hpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,25 +36,25 @@ class StatsdClient {
3636
//!@{
3737

3838
//! Sets a configuration { host, port, prefix }
39-
inline void setConfig(const std::string& host, const uint16_t port, const std::string& prefix) noexcept;
39+
void setConfig(const std::string& host, const uint16_t port, const std::string& prefix) noexcept;
4040

4141
//! Returns the error message as an optional std::string
42-
inline std::optional<std::string> errorMessage() const noexcept;
42+
std::optional<std::string> errorMessage() const noexcept;
4343

4444
//! Increments the key, at a given frequency rate
45-
inline void increment(const std::string& key, const float frequency = 1.0f) const noexcept;
45+
void increment(const std::string& key, const float frequency = 1.0f) const noexcept;
4646

4747
//! Increments the key, at a given frequency rate
48-
inline void decrement(const std::string& key, const float frequency = 1.0f) const noexcept;
48+
void decrement(const std::string& key, const float frequency = 1.0f) const noexcept;
4949

5050
//! Adjusts the specified key by a given delta, at a given frequency rate
51-
inline void count(const std::string& key, const int delta, const float frequency = 1.0f) const noexcept;
51+
void count(const std::string& key, const int delta, const float frequency = 1.0f) const noexcept;
5252

5353
//! Records a gauge for the key, with a given value, at a given frequency rate
54-
inline void gauge(const std::string& key, const unsigned int value, const float frequency = 1.0f) const noexcept;
54+
void gauge(const std::string& key, const unsigned int value, const float frequency = 1.0f) const noexcept;
5555

5656
//! Records a timing for a key, at a given frequency
57-
inline void timing(const std::string& key, const unsigned int ms, const float frequency = 1.0f) const noexcept;
57+
void timing(const std::string& key, const unsigned int ms, const float frequency = 1.0f) const noexcept;
5858

5959
//! Send a value for a key, according to its type, at a given frequency
6060
void send(const std::string& key, const int value, const std::string& type, const float frequency = 1.0f) const
@@ -70,7 +70,7 @@ class StatsdClient {
7070
mutable UDPSender m_sender;
7171
};
7272

73-
StatsdClient::StatsdClient(const std::string& host,
73+
inline StatsdClient::StatsdClient(const std::string& host,
7474
const uint16_t port,
7575
const std::string& prefix,
7676
const std::optional<uint64_t> batchsize) noexcept
@@ -79,36 +79,36 @@ StatsdClient::StatsdClient(const std::string& host,
7979
std::srand(time(nullptr));
8080
}
8181

82-
void StatsdClient::setConfig(const std::string& host, const uint16_t port, const std::string& prefix) noexcept {
82+
inline void StatsdClient::setConfig(const std::string& host, const uint16_t port, const std::string& prefix) noexcept {
8383
m_prefix = prefix;
8484
m_sender.setConfig(host, port);
8585
}
8686

87-
std::optional<std::string> StatsdClient::errorMessage() const noexcept {
87+
inline std::optional<std::string> StatsdClient::errorMessage() const noexcept {
8888
return m_sender.errorMessage();
8989
}
9090

91-
void StatsdClient::decrement(const std::string& key, const float frequency) const noexcept {
91+
inline void StatsdClient::decrement(const std::string& key, const float frequency) const noexcept {
9292
return count(key, -1, frequency);
9393
}
9494

95-
void StatsdClient::increment(const std::string& key, const float frequency) const noexcept {
95+
inline void StatsdClient::increment(const std::string& key, const float frequency) const noexcept {
9696
return count(key, 1, frequency);
9797
}
9898

99-
void StatsdClient::count(const std::string& key, const int delta, const float frequency) const noexcept {
99+
inline void StatsdClient::count(const std::string& key, const int delta, const float frequency) const noexcept {
100100
return send(key, delta, "c", frequency);
101101
}
102102

103-
void StatsdClient::gauge(const std::string& key, const unsigned int value, const float frequency) const noexcept {
103+
inline void StatsdClient::gauge(const std::string& key, const unsigned int value, const float frequency) const noexcept {
104104
return send(key, value, "g", frequency);
105105
}
106106

107-
void StatsdClient::timing(const std::string& key, const unsigned int ms, const float frequency) const noexcept {
107+
inline void StatsdClient::timing(const std::string& key, const unsigned int ms, const float frequency) const noexcept {
108108
return send(key, ms, "ms", frequency);
109109
}
110110

111-
void StatsdClient::send(const std::string& key, const int value, const std::string& type, const float frequency) const
111+
inline void StatsdClient::send(const std::string& key, const int value, const std::string& type, const float frequency) const
112112
noexcept {
113113
const auto isFrequencyOne = [](const float frequency) noexcept {
114114
constexpr float epsilon{0.0001f};

include/cpp-statsd-client/UDPSender.hpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ class UDPSender final {
4343
//!@{
4444

4545
//! Sets a configuration { host, port }
46-
inline void setConfig(const std::string& host, const uint16_t port) noexcept;
46+
void setConfig(const std::string& host, const uint16_t port) noexcept;
4747

4848
//! Send a message
4949
void send(const std::string& message) noexcept;
5050

5151
//! Returns the error message as an optional string
52-
inline std::optional<std::string> errorMessage() const noexcept;
52+
std::optional<std::string> errorMessage() const noexcept;
5353

5454
//!@}
5555

@@ -118,7 +118,7 @@ class UDPSender final {
118118
std::optional<std::string> m_errorMessage;
119119
};
120120

121-
UDPSender::UDPSender(const std::string& host, const uint16_t port, const std::optional<uint64_t> batchsize) noexcept
121+
inline UDPSender::UDPSender(const std::string& host, const uint16_t port, const std::optional<uint64_t> batchsize) noexcept
122122
: m_host(host), m_port(port) {
123123
// If batching is on, use a dedicated thread to send every now and then
124124
if (batchsize) {
@@ -151,7 +151,7 @@ UDPSender::UDPSender(const std::string& host, const uint16_t port, const std::op
151151
}
152152
}
153153

154-
UDPSender::~UDPSender() {
154+
inline UDPSender::~UDPSender() {
155155
if (m_batching) {
156156
m_mustExit = true;
157157
m_batchingThread.join();
@@ -163,7 +163,7 @@ UDPSender::~UDPSender() {
163163
}
164164
}
165165

166-
void UDPSender::setConfig(const std::string& host, const uint16_t port) noexcept {
166+
inline void UDPSender::setConfig(const std::string& host, const uint16_t port) noexcept {
167167
m_host = host;
168168
m_port = port;
169169

@@ -175,7 +175,7 @@ void UDPSender::setConfig(const std::string& host, const uint16_t port) noexcept
175175
m_socket = -1;
176176
}
177177

178-
void UDPSender::send(const std::string& message) noexcept {
178+
inline void UDPSender::send(const std::string& message) noexcept {
179179
// If batching is on, accumulate messages in the queue
180180
if (m_batching) {
181181
std::unique_lock<std::mutex> batchingLock(m_batchingMutex);
@@ -189,11 +189,11 @@ void UDPSender::send(const std::string& message) noexcept {
189189
}
190190
}
191191

192-
std::optional<std::string> UDPSender::errorMessage() const noexcept {
192+
inline std::optional<std::string> UDPSender::errorMessage() const noexcept {
193193
return m_errorMessage;
194194
}
195195

196-
bool UDPSender::initialize() noexcept {
196+
inline bool UDPSender::initialize() noexcept {
197197
using namespace std::string_literals;
198198

199199
if (m_isInitialized) {
@@ -243,7 +243,7 @@ bool UDPSender::initialize() noexcept {
243243
return true;
244244
}
245245

246-
void UDPSender::sendToDaemon(const std::string& message) noexcept {
246+
inline void UDPSender::sendToDaemon(const std::string& message) noexcept {
247247
// Can't send until the sender is initialized
248248
if (!initialize()) {
249249
return;

0 commit comments

Comments
 (0)