Skip to content

Commit 10a7163

Browse files
author
Miguel Barro
committed
Enforce atomic barrier to disable callbacks
1 parent 974d725 commit 10a7163

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

test/performance/throughput/ThroughputPublisher.hpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,14 @@ class ThroughputPublisher
166166
class DataWriterListener : public eprosima::fastdds::dds::DataWriterListener
167167
{
168168
ThroughputPublisher& throughput_publisher_;
169-
int matched_ = 0;
169+
std::atomic_int matched_;
170170

171171
public:
172172

173173
DataWriterListener(
174174
ThroughputPublisher& throughput_publisher)
175175
: throughput_publisher_(throughput_publisher)
176+
, matched_(0)
176177
{
177178
}
178179

@@ -197,13 +198,14 @@ class ThroughputPublisher
197198
class CommandWriterListener : public eprosima::fastdds::dds::DataWriterListener
198199
{
199200
ThroughputPublisher& throughput_publisher_;
200-
int matched_ = 0;
201+
std::atomic_int matched_;
201202

202203
public:
203204

204205
CommandWriterListener(
205206
ThroughputPublisher& throughput_publisher)
206207
: throughput_publisher_(throughput_publisher)
208+
, matched_(0)
207209
{
208210
}
209211

@@ -227,13 +229,14 @@ class ThroughputPublisher
227229
class CommandReaderListener : public eprosima::fastdds::dds::DataReaderListener
228230
{
229231
ThroughputPublisher& throughput_publisher_;
230-
int matched_ = 0;
232+
std::atomic_int matched_;
231233

232234
public:
233235

234236
CommandReaderListener(
235237
ThroughputPublisher& throughput_publisher)
236238
: throughput_publisher_(throughput_publisher)
239+
, matched_(0)
237240
{
238241
}
239242

test/performance/throughput/ThroughputSubscriber.hpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,15 @@ class ThroughputSubscriber
144144
uint32_t last_seq_num_ = 0;
145145
uint32_t lost_samples_ = 0;
146146
eprosima::fastdds::dds::SampleInfo info_;
147-
int matched_ = 0;
148-
bool enable_ = false;
147+
std::atomic_int matched_;
148+
std::atomic_bool enable_;
149149

150150
public:
151151

152152
DataReaderListener(
153153
ThroughputSubscriber& throughput_subscriber)
154154
: throughput_subscriber_(throughput_subscriber)
155+
, matched_(0)
155156
{
156157
}
157158

@@ -182,13 +183,14 @@ class ThroughputSubscriber
182183
class CommandReaderListener : public eprosima::fastdds::dds::DataReaderListener
183184
{
184185
ThroughputSubscriber& throughput_subscriber_;
185-
int matched_ = 0;
186+
std::atomic_int matched_;
186187

187188
public:
188189

189190
CommandReaderListener(
190191
ThroughputSubscriber& throughput_subscriber)
191192
: throughput_subscriber_(throughput_subscriber)
193+
, matched_(0)
192194
{
193195
}
194196

@@ -212,13 +214,14 @@ class ThroughputSubscriber
212214
class CommandWriterListener : public eprosima::fastdds::dds::DataWriterListener
213215
{
214216
ThroughputSubscriber& throughput_subscriber_;
215-
int matched_ = 0;
217+
std::atomic_int matched_;
216218

217219
public:
218220

219221
CommandWriterListener(
220222
ThroughputSubscriber& throughput_subscriber)
221223
: throughput_subscriber_(throughput_subscriber)
224+
, matched_(0)
222225
{
223226
}
224227

0 commit comments

Comments
 (0)