Skip to content

Commit 43090aa

Browse files
ymskiBarry-Xu-2018
authored andcommitted
applied tracepoints for ring_buffer (ros2#2091)
applied tracepoints for intra_publish add tracepoints for linking buffer and subscription Signed-off-by: Kodai Yamasaki <[email protected]>
1 parent 83f87c5 commit 43090aa

File tree

4 files changed

+40
-1
lines changed

4 files changed

+40
-1
lines changed

rclcpp/include/rclcpp/experimental/buffers/intra_process_buffer.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "rclcpp/allocator/allocator_deleter.hpp"
2525
#include "rclcpp/experimental/buffers/buffer_implementation_base.hpp"
2626
#include "rclcpp/macros.hpp"
27+
#include "tracetools/tracetools.h"
2728

2829
namespace rclcpp
2930
{
@@ -94,6 +95,10 @@ class TypedIntraProcessBuffer : public IntraProcessBuffer<MessageT, Alloc, Messa
9495

9596
buffer_ = std::move(buffer_impl);
9697

98+
TRACEPOINT(
99+
rclcpp_buffer_to_ipb,
100+
static_cast<const void *>(buffer_.get()),
101+
static_cast<const void *>(this));
97102
if (!allocator) {
98103
message_allocator_ = std::make_shared<MessageAlloc>();
99104
} else {

rclcpp/include/rclcpp/experimental/buffers/ring_buffer_implementation.hpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "rclcpp/logging.hpp"
2626
#include "rclcpp/macros.hpp"
2727
#include "rclcpp/visibility_control.hpp"
28+
#include "tracetools/tracetools.h"
2829

2930
namespace rclcpp
3031
{
@@ -51,6 +52,7 @@ class RingBufferImplementation : public BufferImplementationBase<BufferT>
5152
if (capacity == 0) {
5253
throw std::invalid_argument("capacity must be a positive, non-zero value");
5354
}
55+
TRACEPOINT(rclcpp_construct_ring_buffer, static_cast<const void *>(this), capacity_);
5456
}
5557

5658
virtual ~RingBufferImplementation() {}
@@ -67,6 +69,12 @@ class RingBufferImplementation : public BufferImplementationBase<BufferT>
6769

6870
write_index_ = next_(write_index_);
6971
ring_buffer_[write_index_] = std::move(request);
72+
TRACEPOINT(
73+
rclcpp_ring_buffer_enqueue,
74+
static_cast<const void *>(this),
75+
write_index_,
76+
size_ + 1,
77+
is_full_());
7078

7179
if (is_full_()) {
7280
read_index_ = next_(read_index_);
@@ -90,6 +98,11 @@ class RingBufferImplementation : public BufferImplementationBase<BufferT>
9098
}
9199

92100
auto request = std::move(ring_buffer_[read_index_]);
101+
TRACEPOINT(
102+
rclcpp_ring_buffer_dequeue,
103+
static_cast<const void *>(this),
104+
read_index_,
105+
size_ - 1);
93106
read_index_ = next_(read_index_);
94107

95108
size_--;
@@ -135,7 +148,10 @@ class RingBufferImplementation : public BufferImplementationBase<BufferT>
135148
return is_full_();
136149
}
137150

138-
void clear() {}
151+
void clear()
152+
{
153+
TRACEPOINT(rclcpp_ring_buffer_clear, static_cast<const void *>(this));
154+
}
139155

140156
private:
141157
/// Get the next index value for the ring buffer

rclcpp/include/rclcpp/experimental/subscription_intra_process_buffer.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
#include "rclcpp/qos.hpp"
3232
#include "rclcpp/type_support_decl.hpp"
3333

34+
#include "tracetools/tracetools.h"
35+
3436
namespace rclcpp
3537
{
3638
namespace experimental
@@ -91,6 +93,10 @@ class SubscriptionIntraProcessBuffer : public SubscriptionROSMsgIntraProcessBuff
9193
buffer_type,
9294
qos_profile,
9395
std::make_shared<Alloc>(subscribed_type_allocator_));
96+
TRACEPOINT(
97+
rclcpp_ipb_to_subscription,
98+
static_cast<const void *>(buffer_.get()),
99+
static_cast<const void *>(this));
94100
}
95101

96102
bool

rclcpp/include/rclcpp/publisher.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,10 @@ class Publisher : public PublisherBase
484484
if (!msg) {
485485
throw std::runtime_error("cannot publish msg which is a null pointer");
486486
}
487+
TRACEPOINT(
488+
rclcpp_intra_publish,
489+
static_cast<const void *>(publisher_handle_.get()),
490+
msg.get());
487491

488492
ipm->template do_intra_process_publish<PublishedType, ROSMessageType, AllocatorT>(
489493
intra_process_publisher_id_,
@@ -502,6 +506,10 @@ class Publisher : public PublisherBase
502506
if (!msg) {
503507
throw std::runtime_error("cannot publish msg which is a null pointer");
504508
}
509+
TRACEPOINT(
510+
rclcpp_intra_publish,
511+
static_cast<const void *>(publisher_handle_.get()),
512+
msg.get());
505513

506514
ipm->template do_intra_process_publish<ROSMessageType, ROSMessageType, AllocatorT>(
507515
intra_process_publisher_id_,
@@ -521,6 +529,10 @@ class Publisher : public PublisherBase
521529
if (!msg) {
522530
throw std::runtime_error("cannot publish msg which is a null pointer");
523531
}
532+
TRACEPOINT(
533+
rclcpp_intra_publish,
534+
static_cast<const void *>(publisher_handle_.get()),
535+
msg.get());
524536

525537
return ipm->template do_intra_process_publish_and_return_shared<ROSMessageType, ROSMessageType,
526538
AllocatorT>(

0 commit comments

Comments
 (0)