Skip to content

Commit

Permalink
Fix TSA warnings when building with clang thread analysis. (ros2#877)
Browse files Browse the repository at this point in the history
In particular, mark consumer_buffer() as ACQUIRE and
release_consumer_buffer() as RELEASE.

Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
  • Loading branch information
clalancette authored and YXL76 committed Nov 18, 2022
1 parent ffd18e7 commit e0582aa
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include <mutex>
#include <string>

#include "rcpputils/thread_safety_annotations.hpp"

#include "rosbag2_cpp/cache/message_cache_circular_buffer.hpp"
#include "rosbag2_cpp/cache/message_cache_interface.hpp"
#include "rosbag2_cpp/cache/cache_buffer_interface.hpp"
Expand Down Expand Up @@ -56,10 +58,11 @@ class ROSBAG2_CPP_PUBLIC CircularMessageCache
/// Get current buffer to consume.
/// Locks consumer_buffer and swap_buffers until release_consumer_buffer is called.
/// This may be repeatedly empty if `swap_buffers` has not been called.
std::shared_ptr<CacheBufferInterface> consumer_buffer() override;
std::shared_ptr<CacheBufferInterface>
consumer_buffer() override RCPPUTILS_TSA_ACQUIRE(consumer_buffer_mutex_);

/// Unlock access to the consumer buffer.
void release_consumer_buffer() override;
void release_consumer_buffer() override RCPPUTILS_TSA_RELEASE(consumer_buffer_mutex_);

/// Swap the primary and secondary buffer before consumption.
/// NOTE: If swap_buffers is called again before consuming via consumer_buffer,
Expand Down

0 comments on commit e0582aa

Please sign in to comment.