Todd Lipcon has posted comments on this change. Change subject: consensus: consolidate Raft thread pools ......................................................................
Patch Set 7: (1 comment) http://gerrit.cloudera.org:8080/#/c/6946/7/src/kudu/consensus/consensus_peers.cc File src/kudu/consensus/consensus_peers.cc: PS7, Line 133: shared_ptr<SequenceToken> locked_token = raft_pool_token_.lock(); : if (!locked_token) { : return Status::ServiceUnavailable("raft thread pool has been shutdown"); : } > +1 I have mixed opinions on this. On the one hand, I see your point that it's safer. However, it's sort of like saying "shared ptrs are safer than unique_ptrs, so we should use them instead." I think in both cases it can be indicative of unclear lifetimes. If you use shared_ptr it's a strong signal that you don't know who will destruct something or who might retain a reference to it. A shared_ptr plus weak_ptr invites the question every time you access the weak_ptr: "is there any guarantee that this is still alive?" If you are 100% sure that it is still alive, then using a raw pointer illustrates that fact, whereas a weak_ptr says "I'm not really sure". There are certainly some cases where "not really sure" is accurate, but I would rather that be an explicit choice due to complex lifetime issues rather than a default which we take due to lack of analysis (aka laziness) -- To view, visit http://gerrit.cloudera.org:8080/6946 To unsubscribe, visit http://gerrit.cloudera.org:8080/settings Gerrit-MessageType: comment Gerrit-Change-Id: I8958c607d11ac2e94908670c985059bef0ff5f54 Gerrit-PatchSet: 7 Gerrit-Project: kudu Gerrit-Branch: master Gerrit-Owner: Adar Dembo <[email protected]> Gerrit-Reviewer: Adar Dembo <[email protected]> Gerrit-Reviewer: Dan Burkert <[email protected]> Gerrit-Reviewer: David Ribeiro Alves <[email protected]> Gerrit-Reviewer: Kudu Jenkins Gerrit-Reviewer: Tidy Bot Gerrit-Reviewer: Todd Lipcon <[email protected]> Gerrit-HasComments: Yes
