Skip to content

Commit

Permalink
sharded: Mark invoke_on_others() helper lambda mutable
Browse files Browse the repository at this point in the history
Otherwise mutable invoke-on-others lambdas fail to compile

   sharded<foo> f;
   f.invoke_on_others([x] (foo& f) mutable { ... });

generates

/home/xemul/src/seastar/include/seastar/core/future.hh:2074:11: error: no type named ‘type’ in ‘struct std::invoke_result<const invoke_on_modifiers::do_run_test_case() const::<lambda(invoke_on_modifiers::do_run_test_case() const::checker&)>&, invoke_on_modifiers::do_run_test_case() const::checker&>’
 2074 |     using futurator = futurize<std::invoke_result_t<Func, Args&&...>>;
      |           ^~~~~~~~~

The invoke_on_all() has its helper lambda mutable so

    sharded<foo> f;
    f.invoke_on_all([x] (foo& x) mutable { ... });

compiles.

Signed-off-by: Pavel Emelyanov <[email protected]>
  • Loading branch information
xemul authored and tchaikov committed Jun 6, 2024
1 parent 50fe23a commit 0bfe012
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion include/seastar/core/sharded.hh
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ sharded<Service>::invoke_on_others(smp_submit_to_options options, Func func, Arg
static_assert(std::is_same_v<futurize_t<std::invoke_result_t<Func, Service&, Args...>>, future<>>,
"invoke_on_others()'s func must return void or future<>");
try {
return invoke_on_all(options, [orig = this_shard_id(), func = std::move(func), args = std::tuple(std::move(args)...)] (Service& s) -> future<> {
return invoke_on_all(options, [orig = this_shard_id(), func = std::move(func), args = std::tuple(std::move(args)...)] (Service& s) mutable -> future<> {
return this_shard_id() == orig ? make_ready_future<>() : futurize_apply(func, std::tuple_cat(std::forward_as_tuple(s), args));;
});
} catch (...) {
Expand Down

0 comments on commit 0bfe012

Please sign in to comment.