Implement move semantics for shared audio buffer

This commit is contained in:
Robbert van der Helm
2021-06-09 20:35:47 +02:00
parent 9d11b501cd
commit 2210cb4fc3
2 changed files with 18 additions and 1 deletions
+10 -1
View File
@@ -30,5 +30,14 @@ AudioShmBuffer::~AudioShmBuffer() noexcept {
// If either side drops this object then the buffer should always be
// removed, so we'll do it on both sides to reduce the chance that we leak
// shared memory
boost::interprocess::shared_memory_object::remove(config.name.c_str());
if (!is_moved) {
boost::interprocess::shared_memory_object::remove(config.name.c_str());
}
}
AudioShmBuffer::AudioShmBuffer(AudioShmBuffer&& o) noexcept
: config(std::move(o.config)),
shm(std::move(o.shm)),
buffer(std::move(o.buffer)) {
o.is_moved = true;
}