]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/crimson/os/alienstore/alien_collection.h
import quincy beta 17.1.0
[ceph.git] / ceph / src / crimson / os / alienstore / alien_collection.h
index 98b8fdef44ddeda8ffd3188727556e0543b9a318..17a930e77a944c774d3b8cbe4e341ae516e27971 100644 (file)
@@ -19,8 +19,21 @@ public:
 
   ~AlienCollection() {}
 
+  template <typename Func, typename Result = std::invoke_result_t<Func>>
+  seastar::futurize_t<Result> with_lock(Func&& func) {
+    // newer versions of Seastar provide two variants of `with_lock`
+    //   - generic, friendly towards throwing move constructors of Func,
+    //   - specialized for `noexcept`.
+    // unfortunately, the former has a limitation: the return value
+    // of `Func` must be compatible with `current_exception_as_future()`
+    // which boils down to returning `seastar::future<void>`.
+    static_assert(std::is_nothrow_move_constructible_v<Func>);
+    return seastar::with_lock(mutex, std::forward<Func>(func));
+  }
+
 private:
   ObjectStore::CollectionHandle collection;
+  seastar::shared_mutex mutex;
   friend AlienStore;
 };
 }