summaryrefslogtreecommitdiff
path: root/modules/remote/c++
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2024-07-21 22:42:22 +0200
committerClaudius "keldu" Holeksa <mail@keldu.de>2024-07-21 22:42:22 +0200
commite5bf2f231e5ebaa13baf0742149d71fc8777e823 (patch)
tree24a7fd45869b86358c9424c438889e7c98e4a203 /modules/remote/c++
parent498acb5ee9db90aaf01049ae44e098169219398d (diff)
Added preallocation to remote
Diffstat (limited to 'modules/remote/c++')
-rw-r--r--modules/remote/c++/transfer_loopback.hpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/modules/remote/c++/transfer_loopback.hpp b/modules/remote/c++/transfer_loopback.hpp
index 9f6dddd..abea83f 100644
--- a/modules/remote/c++/transfer_loopback.hpp
+++ b/modules/remote/c++/transfer_loopback.hpp
@@ -36,11 +36,10 @@ public:
*
*/
template<typename Sch>
- error_or<void> allocate(data<typename meta_schema<Sch>::type, Encoding> meta, id<Sch> store_id){
+ error_or<void> allocate(data<typename meta_schema<Sch>::MetaSchema, Encoding> meta, id<Sch> store_id){
auto& vals = std::get<std::unordered_map<uint64_t, data<Sch,Encoding>>>(values_);
-
try {
- auto insert_res = vals.emplace(std::make_pair(store_id.get_value(), {std::move(meta)}));
+ auto insert_res = vals.emplace(std::make_pair(store_id.get_value(), data<typename meta_schema<Sch>::MetaSchema, Encoding>{std::move(meta)}));
if(!insert_res.second){
return make_error<err::already_exists>();
}
@@ -125,6 +124,21 @@ public:
++next_id_;
return dat_id;
}
+
+ /**
+ * Preallocate data
+ */
+ template<typename Sch>
+ error_or<id<Sch>> allocate(const data<typename meta_schema<Sch>::MetaSchema, Encoding>& meta){
+ id<Sch> dat_id{next_id_};
+ auto eov = srv_->allocate(meta, dat_id);
+ if(eov.is_error()){
+ auto& err = eov.get_error();
+ return std::move(err);
+ }
+ ++next_id_;
+ return dat_id;
+ }
/**
* Receive data