@@ -110,8 +110,8 @@ template <typename T> class ring_buffer_base {
110110 assert_correct_thread (producer_id);
111111#endif
112112
113- int rd_idx = read_index_.load (std::memory_order_relaxed);
114113 int wr_idx = write_index_.load (std::memory_order_relaxed);
114+ int rd_idx = read_index_.load (std::memory_order_acquire);
115115
116116 if (full_internal (rd_idx, wr_idx)) {
117117 return 0 ;
@@ -154,8 +154,8 @@ template <typename T> class ring_buffer_base {
154154 assert_correct_thread (consumer_id);
155155#endif
156156
157- int wr_idx = write_index_.load (std::memory_order_acquire);
158157 int rd_idx = read_index_.load (std::memory_order_relaxed);
158+ int wr_idx = write_index_.load (std::memory_order_acquire);
159159
160160 if (empty_internal (rd_idx, wr_idx)) {
161161 return 0 ;
@@ -172,7 +172,7 @@ template <typename T> class ring_buffer_base {
172172 }
173173
174174 read_index_.store (increment_index (rd_idx, to_read),
175- std::memory_order_relaxed );
175+ std::memory_order_release );
176176
177177 return to_read;
178178 }
@@ -190,7 +190,7 @@ template <typename T> class ring_buffer_base {
190190#endif
191191 return available_read_internal (
192192 read_index_.load (std::memory_order_relaxed),
193- write_index_.load (std::memory_order_relaxed ));
193+ write_index_.load (std::memory_order_acquire ));
194194 }
195195 /* *
196196 * Get the number of available elements for consuming.
@@ -205,7 +205,7 @@ template <typename T> class ring_buffer_base {
205205 assert_correct_thread (producer_id);
206206#endif
207207 return available_write_internal (
208- read_index_.load (std::memory_order_relaxed ),
208+ read_index_.load (std::memory_order_acquire ),
209209 write_index_.load (std::memory_order_relaxed));
210210 }
211211 /* *
0 commit comments