]> git.proxmox.com Git - ceph.git/blob - ceph/src/crimson/os/alienstore/alien_collection.h
import quincy beta 17.1.0
[ceph.git] / ceph / src / crimson / os / alienstore / alien_collection.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3
4 #pragma once
5
6 #include "os/ObjectStore.h"
7
8 #include "crimson/os/futurized_collection.h"
9 #include "crimson/os/futurized_store.h"
10 #include "alien_store.h"
11
12 namespace crimson::os {
13
14 class AlienCollection final : public FuturizedCollection {
15 public:
16 AlienCollection(ObjectStore::CollectionHandle ch)
17 : FuturizedCollection(ch->cid),
18 collection(ch) {}
19
20 ~AlienCollection() {}
21
22 template <typename Func, typename Result = std::invoke_result_t<Func>>
23 seastar::futurize_t<Result> with_lock(Func&& func) {
24 // newer versions of Seastar provide two variants of `with_lock`
25 // - generic, friendly towards throwing move constructors of Func,
26 // - specialized for `noexcept`.
27 // unfortunately, the former has a limitation: the return value
28 // of `Func` must be compatible with `current_exception_as_future()`
29 // which boils down to returning `seastar::future<void>`.
30 static_assert(std::is_nothrow_move_constructible_v<Func>);
31 return seastar::with_lock(mutex, std::forward<Func>(func));
32 }
33
34 private:
35 ObjectStore::CollectionHandle collection;
36 seastar::shared_mutex mutex;
37 friend AlienStore;
38 };
39 }