braft
braft copied to clipboard
Can `_node->is_leader()` be used?
The examples use a _leader_term variable to check if the current node is a leader:
https://github.com/baidu/braft/blob/master/example/counter/server.cpp#L153
Instead, can one use _node->is_leader()?
https://github.com/baidu/braft/blob/master/src/braft/raft.h#L619
What's the difference between these 2 different approaches?
I'm guessing the big difference be that Node::is_leader() try to acquire a bthread_mutex_t before reading the |_state|, while the fsm(example::Counter) just use an atomic load