summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2021-11-02 08:39:44 +0100
committerSven Gothel <[email protected]>2021-11-02 08:39:44 +0100
commit68ed3fb1192c141cc343bcf998cc7a0c40be88b5 (patch)
tree9a7bd43bcbe7d1d7f9919f926a720d81d1e2f63f
parent62fd2799eec1ee9c70ab21653b6e0468efe55740 (diff)
ringbuffer::moveIntoImpl(): Apply same 'integral, memcpy' path as for copyIntoImpl()
Ensure consistent behavior and same optimization.
-rw-r--r--include/jau/ringbuffer.hpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/include/jau/ringbuffer.hpp b/include/jau/ringbuffer.hpp
index dc3309d..a2b201e 100644
--- a/include/jau/ringbuffer.hpp
+++ b/include/jau/ringbuffer.hpp
@@ -606,7 +606,15 @@ class ringbuffer {
return false;
}
}
- new (const_cast<pointer_mutable>(array + localWritePos)) value_type( std::move(e) ); // placement new
+ if constexpr ( is_integral ) {
+ array[localWritePos] = e;
+ } else if constexpr ( uses_memcpy ) {
+ ::memcpy(voidptr_cast(&array[localWritePos]),
+ &e,
+ sizeof(Value_type));
+ } else {
+ new (const_cast<pointer_mutable>(array + localWritePos)) value_type( std::move(e) ); // placement new
+ }
{
std::unique_lock<std::mutex> lockWrite(syncWrite); // SC-DRF w/ getImpl via same lock
writePos = localWritePos; // SC-DRF release atomic writePos