From b2bc35500da25781bed5ae10e4d0507e32507e9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Mon, 22 Jul 2024 12:18:48 +0200 Subject: [PATCH] Same for store API --- include/openPMD/LoadStoreChunk.hpp | 4 +++- src/LoadStoreChunk.cpp | 24 +++++++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/include/openPMD/LoadStoreChunk.hpp b/include/openPMD/LoadStoreChunk.hpp index 01538c1a5e..d25f2d3510 100644 --- a/include/openPMD/LoadStoreChunk.hpp +++ b/include/openPMD/LoadStoreChunk.hpp @@ -164,7 +164,9 @@ namespace core auto storeChunkConfig() -> internal::LoadStoreConfigWithBuffer; - auto enqueueStore() -> void; + auto enqueueStore() -> std::future; + + auto store(EnqueuePolicy) -> void; /** This intentionally shadows the parent class's enqueueLoad methods in * order to show a compile error when using enqueueLoad() on an object diff --git a/src/LoadStoreChunk.cpp b/src/LoadStoreChunk.cpp index cd9cb347f9..52ef46b189 100644 --- a/src/LoadStoreChunk.cpp +++ b/src/LoadStoreChunk.cpp @@ -202,12 +202,34 @@ namespace core } template - auto ConfigureStoreChunkFromBuffer::enqueueStore() -> void + auto + ConfigureStoreChunkFromBuffer::enqueueStore() -> std::future + { + this->m_rc.storeChunk_impl( + asWriteBuffer(std::move(m_buffer)), + determineDatatype>(), + storeChunkConfig()); + return std::async( + std::launch::deferred, + [rc_lambda = m_rc]() mutable -> void { rc_lambda.seriesFlush(); }); + } + + template + auto + ConfigureStoreChunkFromBuffer::store(EnqueuePolicy ep) -> void { this->m_rc.storeChunk_impl( asWriteBuffer(std::move(m_buffer)), determineDatatype>(), storeChunkConfig()); + switch (ep) + { + case EnqueuePolicy::Defer: + break; + case EnqueuePolicy::Immediate: + m_rc.seriesFlush(); + break; + } } template