Skip to content

Commit bfc91b8

Browse files
authored
refactor: Avoid using lvalue ref in context.hxx (#636)
1 parent 2acbbe1 commit bfc91b8

File tree

1 file changed

+17
-20
lines changed

1 file changed

+17
-20
lines changed

include/libnuraft/context.hxx

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -40,32 +40,29 @@ class state_mgr;
4040
class global_mgr;
4141
struct context {
4242
public:
43-
context( ptr<state_mgr>& mgr,
44-
ptr<state_machine>& m,
45-
ptr<rpc_listener>& listener,
46-
ptr<logger>& l,
47-
ptr<rpc_client_factory>& cli_factory,
48-
ptr<delayed_task_scheduler>& scheduler,
49-
const raft_params& params,
50-
global_mgr* custom_global_mgr = nullptr)
51-
: state_mgr_(mgr)
52-
, state_machine_(m)
53-
, rpc_listener_(listener)
54-
, logger_(l)
55-
, rpc_cli_factory_(cli_factory)
56-
, scheduler_(scheduler)
43+
context(ptr<state_mgr> mgr,
44+
ptr<state_machine> m,
45+
ptr<rpc_listener> listener,
46+
ptr<logger> l,
47+
ptr<rpc_client_factory> cli_factory,
48+
ptr<delayed_task_scheduler> scheduler,
49+
const raft_params& params,
50+
global_mgr* custom_global_mgr = nullptr)
51+
: state_mgr_(std::move(mgr))
52+
, state_machine_(std::move(m))
53+
, rpc_listener_(std::move(listener))
54+
, logger_(std::move(l))
55+
, rpc_cli_factory_(std::move(cli_factory))
56+
, scheduler_(std::move(scheduler))
5757
, params_(cs_new<raft_params>(params))
58-
, custom_global_mgr_(custom_global_mgr)
59-
{}
58+
, custom_global_mgr_(custom_global_mgr) {}
6059

6160
/**
6261
* Register an event callback function.
6362
*
6463
* @param func Callback function to register.
6564
*/
66-
void set_cb_func(cb_func::func_type func) {
67-
cb_func_ = cb_func(func);
68-
}
65+
void set_cb_func(cb_func::func_type func) { cb_func_ = cb_func(func); }
6966

7067
/**
7168
* Return the pointer to current Raft parameters.
@@ -147,6 +144,6 @@ public:
147144
mutable std::mutex ctx_lock_;
148145
};
149146

150-
}
147+
} // namespace nuraft
151148

152149
#endif //_CONTEXT_HXX_

0 commit comments

Comments
 (0)