Skip to content

Commit

Permalink
Add mutable to with_lock and do_with
Browse files Browse the repository at this point in the history
Fix the following compiling error

scylla/seastar/core/do_with.hh:79:20:
error: no match for call to ‘(const service::storage_service::run_with_write_api_lock(Func&&)::<lambda(service::storage_service&)> mutable [with Func =
service::storage_service::decommission()::<lambda(service::storage_service&)>]::<lambda()>) ()’
         return func();
                    ^
In file included from service/storage_service.cc:40:0:
service/storage_service.hh:2590:99: note: candidate:
service::storage_service::run_with_write_api_lock(Func&&)::<lambda(service::storage_service&)>
mutable::<lambda()> mutable [with Func =
service::storage_service::decommission()::<lambda(service::storage_service&)>]
<near match>
             return with_lock(ss.api_lock().for_write(), [&ss, func =
std::forward<Func>(func)] () mutable {
                                                                                                   ^
service/storage_service.hh:2590:99: note:
passing ‘const service::storage_service::run_with_write_api_lock(Func&&)::<lambda(service::storage_service&)> mutable [with Func =
service::storage_service::decommission()::<lambda(service::storage_service&)>]::<lambda()>*’
as ‘this’ argument discards qualifiers
  • Loading branch information
asias authored and avikivity committed Oct 27, 2015
1 parent 6436bb6 commit 9d8913a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion core/do_with.hh
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ cherry_pick_tuple(std::index_sequence<Idx...>, Tuple&& tuple) {
template<typename Lock, typename Func>
inline
auto with_lock(Lock& lock, Func&& func) {
return lock.lock().then([func = std::forward<Func>(func)] {
return lock.lock().then([func = std::forward<Func>(func)] () mutable {
return func();
}).finally([&lock] { lock.unlock(); });
}
Expand Down
2 changes: 1 addition & 1 deletion core/thread.hh
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ async(Func&& func, Args&&... args) {
promise<return_type> pr;
thread th;
};
return do_with(work{std::forward<Func>(func), std::forward_as_tuple(std::forward<Args>(args)...)}, [] (work& w) {
return do_with(work{std::forward<Func>(func), std::forward_as_tuple(std::forward<Args>(args)...)}, [] (work& w) mutable {
auto ret = w.pr.get_future();
w.th = thread([&w] {
futurize<return_type>::apply(std::move(w.func), std::move(w.args)).forward_to(std::move(w.pr));
Expand Down

0 comments on commit 9d8913a

Please sign in to comment.