Skip to content

Commit

Permalink
Same for store API
Browse files Browse the repository at this point in the history
  • Loading branch information
franzpoeschel committed Jul 22, 2024
1 parent f1bb42a commit b2bc355
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
4 changes: 3 additions & 1 deletion include/openPMD/LoadStoreChunk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ namespace core

auto storeChunkConfig() -> internal::LoadStoreConfigWithBuffer;

auto enqueueStore() -> void;
auto enqueueStore() -> std::future<void>;

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
Expand Down
24 changes: 23 additions & 1 deletion src/LoadStoreChunk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,34 @@ namespace core
}

template <typename Ptr_Type>
auto ConfigureStoreChunkFromBuffer<Ptr_Type>::enqueueStore() -> void
auto
ConfigureStoreChunkFromBuffer<Ptr_Type>::enqueueStore() -> std::future<void>
{
this->m_rc.storeChunk_impl(
asWriteBuffer(std::move(m_buffer)),
determineDatatype<auxiliary::IsPointer_t<Ptr_Type>>(),
storeChunkConfig());
return std::async(
std::launch::deferred,
[rc_lambda = m_rc]() mutable -> void { rc_lambda.seriesFlush(); });
}

template <typename Ptr_Type>
auto
ConfigureStoreChunkFromBuffer<Ptr_Type>::store(EnqueuePolicy ep) -> void
{
this->m_rc.storeChunk_impl(
asWriteBuffer(std::move(m_buffer)),
determineDatatype<auxiliary::IsPointer_t<Ptr_Type>>(),
storeChunkConfig());
switch (ep)
{
case EnqueuePolicy::Defer:
break;
case EnqueuePolicy::Immediate:
m_rc.seriesFlush();
break;
}
}

template <typename Ptr_Type>
Expand Down

0 comments on commit b2bc355

Please sign in to comment.