1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
6 #include "os/ObjectStore.h"
8 #include "crimson/os/futurized_collection.h"
9 #include "crimson/os/futurized_store.h"
10 #include "alien_store.h"
12 namespace crimson::os
{
14 class AlienCollection final
: public FuturizedCollection
{
16 AlienCollection(ObjectStore::CollectionHandle ch
)
17 : FuturizedCollection(ch
->cid
),
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
));
35 ObjectStore::CollectionHandle collection
;
36 seastar::shared_mutex mutex
;