Skip to content

Commit c4d415d

Browse files
Deprecate msg_ field (#421)
1 parent f337644 commit c4d415d

File tree

1 file changed

+50
-1
lines changed

1 file changed

+50
-1
lines changed

realtime_tools/include/realtime_tools/realtime_publisher.hpp

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ class RealtimePublisher
6363

6464
RCLCPP_SMART_PTR_DEFINITIONS(RealtimePublisher<MessageT>)
6565

66+
[[deprecated(
67+
"This variable is deprecated, it is recommended to use the try_publish() method instead.")]]
6668
MessageT msg_;
6769

6870
/**
@@ -74,6 +76,13 @@ class RealtimePublisher
7476
*
7577
* \param publisher the ROS publisher to wrap
7678
*/
79+
#ifdef _MSC_VER
80+
#pragma warning(push)
81+
#pragma warning(disable : 4996)
82+
#else
83+
#pragma GCC diagnostic push
84+
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
85+
#endif
7786
explicit RealtimePublisher(PublisherSharedPtr publisher)
7887
: publisher_(publisher), is_running_(false), keep_running_(true), turn_(State::LOOP_NOT_STARTED)
7988
{
@@ -102,6 +111,11 @@ class RealtimePublisher
102111
thread_.join();
103112
}
104113
}
114+
#ifdef _MSC_VER
115+
#pragma warning(pop)
116+
#else
117+
#pragma GCC diagnostic pop
118+
#endif
105119

106120
/**
107121
* \brief Stop the realtime publisher
@@ -161,7 +175,19 @@ class RealtimePublisher
161175
if (can_publish(lock)) {
162176
{
163177
std::unique_lock<std::mutex> scoped_lock(std::move(lock));
178+
#ifdef _MSC_VER
179+
#pragma warning(push)
180+
#pragma warning(disable : 4996)
181+
#else
182+
#pragma GCC diagnostic push
183+
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
184+
#endif
164185
msg_ = msg;
186+
#ifdef _MSC_VER
187+
#pragma warning(pop)
188+
#else
189+
#pragma GCC diagnostic pop
190+
#endif
165191
turn_.store(State::NON_REALTIME, std::memory_order_release);
166192
}
167193
updated_cond_.notify_one(); // Notify the publishing thread
@@ -238,8 +264,19 @@ class RealtimePublisher
238264
std::thread & get_thread() { return thread_; }
239265

240266
const std::thread & get_thread() const { return thread_; }
241-
267+
#ifdef _MSC_VER
268+
#pragma warning(push)
269+
#pragma warning(disable : 4996)
270+
#else
271+
#pragma GCC diagnostic push
272+
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
273+
#endif
242274
const MessageT & get_msg() const { return msg_; }
275+
#ifdef _MSC_VER
276+
#pragma warning(pop)
277+
#else
278+
#pragma GCC diagnostic pop
279+
#endif
243280

244281
std::mutex & get_mutex() { return msg_mutex_; }
245282

@@ -286,7 +323,19 @@ class RealtimePublisher
286323
// Locks msg_ and copies it to outgoing
287324
std::unique_lock<std::mutex> lock_(msg_mutex_);
288325
updated_cond_.wait(lock_, [&] { return turn_ == State::NON_REALTIME || !keep_running_; });
326+
#ifdef _MSC_VER
327+
#pragma warning(push)
328+
#pragma warning(disable : 4996)
329+
#else
330+
#pragma GCC diagnostic push
331+
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
332+
#endif
289333
outgoing = msg_;
334+
#ifdef _MSC_VER
335+
#pragma warning(pop)
336+
#else
337+
#pragma GCC diagnostic pop
338+
#endif
290339
}
291340

292341
// Sends the outgoing message

0 commit comments

Comments
 (0)