Adar Dembo has posted comments on this change. (
http://gerrit.cloudera.org:8080/15307 )
Change subject: [tserver] report the newly bootstrapped tablet after OpenTablet
completes
......................................................................
Patch Set 10:
(2 comments)
It's frustrating that C++ doesn't offer a way to pass an exclusively owned
object (i.e. unique_ptr<Foo>) into a std::bind call and store the result in an
std::function. I tried the following code, but it doesn't compile:
void TakesOwnership(std::unique_ptr<Foo> arg) {}
auto f = std::make_unique<Foo>();
// f becomes null during the following call.
auto cb = std::bind(&TakesOwnership, std::move(f));
The closest thing to this is C++14 lambda capture semantics, which allow
capture-by-move. In this case, you could capture-by-move the deleter into a
lambda which invokes DeleteTablet, then submit that lambda as a functor to the
threadpool. But, we don't support C++14 yet. :/
If you prefer, you can adapt OpenTablet to use gutil/callback.h-style functors,
which will allow you to wrap the deleter in a kudu::Passed() wrapper and, in
OpenTablet, "unwrap" it into a gscoped_ptr. But given that we've been trying to
move away from gscoped_ptr usage, maybe that's a step in the wrong direction.
http://gerrit.cloudera.org:8080/#/c/15307/10/src/kudu/tserver/ts_tablet_manager.h
File src/kudu/tserver/ts_tablet_manager.h:
http://gerrit.cloudera.org:8080/#/c/15307/10/src/kudu/tserver/ts_tablet_manager.h@421
PS10, Line 421: friend class
RefCountedThreadSafe<TransitionInProgressDeleter>;
Can remove this too.
http://gerrit.cloudera.org:8080/#/c/15307/10/src/kudu/tserver/ts_tablet_manager.cc
File src/kudu/tserver/ts_tablet_manager.cc:
http://gerrit.cloudera.org:8080/#/c/15307/10/src/kudu/tserver/ts_tablet_manager.cc@1080
PS10, Line 1080: TransitionInProgressDeleter*
deleter) {
If you immediately put this in a unique_ptr you can avoid the delete calls.
--
To view, visit http://gerrit.cloudera.org:8080/15307
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I591dc8daceb81f9e800098be77c928d391cdc00a
Gerrit-Change-Number: 15307
Gerrit-PatchSet: 10
Gerrit-Owner: Yifan Zhang <[email protected]>
Gerrit-Reviewer: Adar Dembo <[email protected]>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Yifan Zhang <[email protected]>
Gerrit-Comment-Date: Wed, 04 Mar 2020 06:57:20 +0000
Gerrit-HasComments: Yes