You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by da...@apache.org on 2016/06/02 00:52:53 UTC
[1/5] incubator-kudu git commit: Add a few more release notes for
0.9.0
Repository: incubator-kudu
Updated Branches:
refs/heads/master 48e09ab95 -> 8a75ceeee
Add a few more release notes for 0.9.0
Change-Id: Ibbd66838b51e467d4c4808fa09972d0cba717143
Reviewed-on: http://gerrit.cloudera.org:8080/3273
Tested-by: Kudu Jenkins
Reviewed-by: Misty Stanley-Jones <mi...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/incubator-kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-kudu/commit/0e9fd8c1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-kudu/tree/0e9fd8c1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-kudu/diff/0e9fd8c1
Branch: refs/heads/master
Commit: 0e9fd8c155e895af0c652267575c88b55172ce9e
Parents: 48e09ab
Author: Jean-Daniel Cryans <jd...@apache.org>
Authored: Wed Jun 1 12:48:04 2016 -0700
Committer: Jean-Daniel Cryans <jd...@gerrit.cloudera.org>
Committed: Thu Jun 2 00:48:50 2016 +0000
----------------------------------------------------------------------
docs/release_notes.adoc | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/0e9fd8c1/docs/release_notes.adoc
----------------------------------------------------------------------
diff --git a/docs/release_notes.adoc b/docs/release_notes.adoc
index e912455..f88ecb6 100644
--- a/docs/release_notes.adoc
+++ b/docs/release_notes.adoc
@@ -97,6 +97,28 @@ To upgrade to Kudu 0.9.0, see link:installation.html#upgrade[Upgrade from 0.8.0
- link:http://gerrit.cloudera.org:8080/#/c/2992/[Gerrit 2992] Added the ability
to update and insert from Spark using a Kudu datasource.
+[[rn_0.9.0_improvements]]
+==== Improvements
+
+- link:https://issues.apache.org/jira/browse/KUDU-1415[KUDU-1415] Added statistics in the Java
+ client such as the number of bytes written and the number of operations applied.
+
+- link:https://issues.apache.org/jira/browse/KUDU-1451[KUDU-1451] Improved tablet server restart
+ time when the tablet server needs to clean up of a lot previously deleted tablets. Tablets are
+ now cleaned up after they are deleted.
+
+[[rn_0.9.0_fixed_issues]]
+==== Fixed Issues
+
+- link:https://issues.apache.org/jira/browse/KUDU-678[KUDU-678] Fixed a leak that happened during
+ DiskRowSet compactions where tiny blocks were still written to disk even if there were no REDO
+ records. With the default block manager, it usually resulted in block containers with thousands
+ of tiny blocks.
+
+- link:https://issues.apache.org/jira/browse/KUDU-1437[KUDU-1437] Fixed a data corruption issue
+ that occured after compacting sequences of negative INT32 values in a column that
+ was configured with RLE encoding.
+
[[rn_0.9.0_changes]]
==== Other noteworthy changes
[2/5] incubator-kudu git commit: Replace boost::{lock, unique_lock,
mutex} with std lib equivalents
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/tablet/mvcc.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/mvcc.cc b/src/kudu/tablet/mvcc.cc
index f972379..2ce0237 100644
--- a/src/kudu/tablet/mvcc.cc
+++ b/src/kudu/tablet/mvcc.cc
@@ -15,10 +15,11 @@
// specific language governing permissions and limitations
// under the License.
+#include "kudu/tablet/mvcc.h"
+
#include <algorithm>
-#include <boost/thread/locks.hpp>
-#include <boost/thread/mutex.hpp>
#include <glog/logging.h>
+#include <mutex>
#include "kudu/gutil/map-util.h"
#include "kudu/gutil/mathlimits.h"
@@ -27,7 +28,6 @@
#include "kudu/gutil/strings/strcat.h"
#include "kudu/gutil/strings/substitute.h"
#include "kudu/server/logical_clock.h"
-#include "kudu/tablet/mvcc.h"
#include "kudu/util/countdown_latch.h"
#include "kudu/util/debug/trace_event.h"
#include "kudu/util/stopwatch.h"
@@ -45,7 +45,7 @@ MvccManager::MvccManager(const scoped_refptr<server::Clock>& clock)
Timestamp MvccManager::StartTransaction() {
while (true) {
Timestamp now = clock_->Now();
- boost::lock_guard<LockType> l(lock_);
+ std::lock_guard<LockType> l(lock_);
if (PREDICT_TRUE(InitTransactionUnlocked(now))) {
return now;
}
@@ -56,7 +56,7 @@ Timestamp MvccManager::StartTransaction() {
}
Timestamp MvccManager::StartTransactionAtLatest() {
- boost::lock_guard<LockType> l(lock_);
+ std::lock_guard<LockType> l(lock_);
Timestamp now_latest = clock_->NowLatest();
while (PREDICT_FALSE(!InitTransactionUnlocked(now_latest))) {
now_latest = clock_->NowLatest();
@@ -76,7 +76,7 @@ Timestamp MvccManager::StartTransactionAtLatest() {
}
Status MvccManager::StartTransactionAtTimestamp(Timestamp timestamp) {
- boost::lock_guard<LockType> l(lock_);
+ std::lock_guard<LockType> l(lock_);
if (PREDICT_FALSE(cur_snap_.IsCommitted(timestamp))) {
return Status::IllegalState(
strings::Substitute("Timestamp: $0 is already committed. Current Snapshot: $1",
@@ -91,7 +91,7 @@ Status MvccManager::StartTransactionAtTimestamp(Timestamp timestamp) {
}
void MvccManager::StartApplyingTransaction(Timestamp timestamp) {
- boost::lock_guard<LockType> l(lock_);
+ std::lock_guard<LockType> l(lock_);
auto it = timestamps_in_flight_.find(timestamp.value());
if (PREDICT_FALSE(it == timestamps_in_flight_.end())) {
LOG(FATAL) << "Cannot mark timestamp " << timestamp.ToString() << " as APPLYING: "
@@ -131,7 +131,7 @@ bool MvccManager::InitTransactionUnlocked(const Timestamp& timestamp) {
}
void MvccManager::CommitTransaction(Timestamp timestamp) {
- boost::lock_guard<LockType> l(lock_);
+ std::lock_guard<LockType> l(lock_);
bool was_earliest = false;
CommitTransactionUnlocked(timestamp, &was_earliest);
@@ -149,7 +149,7 @@ void MvccManager::CommitTransaction(Timestamp timestamp) {
}
void MvccManager::AbortTransaction(Timestamp timestamp) {
- boost::lock_guard<LockType> l(lock_);
+ std::lock_guard<LockType> l(lock_);
// Remove from our in-flight list.
TxnState old_state = RemoveInFlightAndGetStateUnlocked(timestamp);
@@ -164,7 +164,7 @@ void MvccManager::AbortTransaction(Timestamp timestamp) {
}
void MvccManager::OfflineCommitTransaction(Timestamp timestamp) {
- boost::lock_guard<LockType> l(lock_);
+ std::lock_guard<LockType> l(lock_);
// Commit the transaction, but do not adjust 'all_committed_before_', that will
// be done with a separate OfflineAdjustCurSnap() call.
@@ -226,7 +226,7 @@ void MvccManager::AdvanceEarliestInFlightTimestamp() {
}
void MvccManager::OfflineAdjustSafeTime(Timestamp safe_time) {
- boost::lock_guard<LockType> l(lock_);
+ std::lock_guard<LockType> l(lock_);
// No more transactions will start with a ts that is lower than or equal
// to 'safe_time', so we adjust the snapshot accordingly.
@@ -302,7 +302,7 @@ Status MvccManager::WaitUntil(WaitFor wait_for, Timestamp ts,
waiting_state.latch = &latch;
waiting_state.wait_for = wait_for;
- boost::lock_guard<LockType> l(lock_);
+ std::lock_guard<LockType> l(lock_);
if (IsDoneWaitingUnlocked(waiting_state)) return Status::OK();
waiters_.push_back(&waiting_state);
}
@@ -311,7 +311,7 @@ Status MvccManager::WaitUntil(WaitFor wait_for, Timestamp ts,
}
// We timed out. We need to clean up our entry in the waiters_ array.
- boost::lock_guard<LockType> l(lock_);
+ std::lock_guard<LockType> l(lock_);
// It's possible that while we were re-acquiring the lock, we did get
// notified. In that case, we have no cleanup to do.
if (waiting_state.latch->count() == 0) {
@@ -355,7 +355,7 @@ bool MvccManager::AnyApplyingAtOrBeforeUnlocked(Timestamp ts) const {
}
void MvccManager::TakeSnapshot(MvccSnapshot *snap) const {
- boost::lock_guard<LockType> l(lock_);
+ std::lock_guard<LockType> l(lock_);
*snap = cur_snap_;
}
@@ -379,7 +379,7 @@ void MvccManager::WaitForApplyingTransactionsToCommit() const {
// Find the highest timestamp of an APPLYING transaction.
Timestamp wait_for = Timestamp::kMin;
{
- boost::lock_guard<LockType> l(lock_);
+ std::lock_guard<LockType> l(lock_);
for (const InFlightMap::value_type entry : timestamps_in_flight_) {
if (entry.second == APPLYING) {
wait_for = Timestamp(std::max(entry.first, wait_for.value()));
@@ -399,22 +399,22 @@ void MvccManager::WaitForApplyingTransactionsToCommit() const {
}
bool MvccManager::AreAllTransactionsCommitted(Timestamp ts) const {
- boost::lock_guard<LockType> l(lock_);
+ std::lock_guard<LockType> l(lock_);
return AreAllTransactionsCommittedUnlocked(ts);
}
int MvccManager::CountTransactionsInFlight() const {
- boost::lock_guard<LockType> l(lock_);
+ std::lock_guard<LockType> l(lock_);
return timestamps_in_flight_.size();
}
Timestamp MvccManager::GetCleanTimestamp() const {
- boost::lock_guard<LockType> l(lock_);
+ std::lock_guard<LockType> l(lock_);
return cur_snap_.all_committed_before_;
}
void MvccManager::GetApplyingTransactionsTimestamps(std::vector<Timestamp>* timestamps) const {
- boost::lock_guard<LockType> l(lock_);
+ std::lock_guard<LockType> l(lock_);
timestamps->reserve(timestamps_in_flight_.size());
for (const InFlightMap::value_type entry : timestamps_in_flight_) {
if (entry.second == APPLYING) {
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/tablet/rowset.h
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/rowset.h b/src/kudu/tablet/rowset.h
index 4890410..6e55bf0 100644
--- a/src/kudu/tablet/rowset.h
+++ b/src/kudu/tablet/rowset.h
@@ -17,8 +17,8 @@
#ifndef KUDU_TABLET_ROWSET_H
#define KUDU_TABLET_ROWSET_H
-#include <boost/thread/mutex.hpp>
#include <memory>
+#include <mutex>
#include <string>
#include <vector>
@@ -119,7 +119,7 @@ class RowSet {
// Return the lock used for including this DiskRowSet in a compaction.
// This prevents multiple compactions and flushes from trying to include
// the same rowset.
- virtual boost::mutex *compact_flush_lock() = 0;
+ virtual std::mutex *compact_flush_lock() = 0;
// Returns the metadata associated with this rowset.
virtual std::shared_ptr<RowSetMetadata> metadata() = 0;
@@ -157,7 +157,7 @@ class RowSet {
// the compaction selection has finished because only one thread
// makes compaction selection at a time on a given Tablet due to
// Tablet::compact_select_lock_.
- boost::mutex::scoped_try_lock try_lock(*compact_flush_lock());
+ std::unique_lock<std::mutex> try_lock(*compact_flush_lock(), std::try_to_lock);
return try_lock.owns_lock();
}
@@ -283,7 +283,7 @@ class DuplicatingRowSet : public RowSet {
std::shared_ptr<RowSetMetadata> metadata() OVERRIDE;
// A flush-in-progress rowset should never be selected for compaction.
- boost::mutex *compact_flush_lock() OVERRIDE {
+ std::mutex *compact_flush_lock() OVERRIDE {
LOG(FATAL) << "Cannot be compacted";
return NULL;
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/tablet/tablet.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/tablet.cc b/src/kudu/tablet/tablet.cc
index d12343c..59873c1 100644
--- a/src/kudu/tablet/tablet.cc
+++ b/src/kudu/tablet/tablet.cc
@@ -15,13 +15,14 @@
// specific language governing permissions and limitations
// under the License.
+#include "kudu/tablet/tablet.h"
+
#include <algorithm>
-#include <boost/bind.hpp>
-#include <boost/thread/locks.hpp>
-#include <boost/thread/mutex.hpp>
+#include <boost/thread/shared_mutex.hpp>
#include <iterator>
#include <limits>
#include <memory>
+#include <mutex>
#include <ostream>
#include <unordered_set>
#include <utility>
@@ -50,7 +51,6 @@
#include "kudu/tablet/rowset_info.h"
#include "kudu/tablet/rowset_tree.h"
#include "kudu/tablet/svg_dump.h"
-#include "kudu/tablet/tablet.h"
#include "kudu/tablet/tablet_metrics.h"
#include "kudu/tablet/tablet_mm_ops.h"
#include "kudu/tablet/transactions/alter_schema_transaction.h"
@@ -204,7 +204,7 @@ Tablet::~Tablet() {
Status Tablet::Open() {
TRACE_EVENT0("tablet", "Tablet::Open");
- boost::lock_guard<rw_spinlock> lock(component_lock_);
+ std::lock_guard<rw_spinlock> lock(component_lock_);
CHECK_EQ(state_, kInitialized) << "already open";
CHECK(schema()->has_column_ids());
@@ -245,7 +245,7 @@ void Tablet::MarkFinishedBootstrapping() {
void Tablet::Shutdown() {
UnregisterMaintenanceOps();
- boost::lock_guard<rw_spinlock> lock(component_lock_);
+ std::lock_guard<rw_spinlock> lock(component_lock_);
components_ = nullptr;
state_ = kShutdown;
@@ -665,7 +665,7 @@ void Tablet::ModifyRowSetTree(const RowSetTree& old_tree,
void Tablet::AtomicSwapRowSets(const RowSetVector &old_rowsets,
const RowSetVector &new_rowsets) {
- boost::lock_guard<rw_spinlock> lock(component_lock_);
+ std::lock_guard<rw_spinlock> lock(component_lock_);
AtomicSwapRowSetsUnlocked(old_rowsets, new_rowsets);
}
@@ -690,7 +690,7 @@ Status Tablet::DoMajorDeltaCompaction(const vector<ColumnId>& col_ids,
Status Tablet::Flush() {
TRACE_EVENT1("tablet", "Tablet::Flush", "id", tablet_id());
- boost::lock_guard<Semaphore> lock(rowsets_flush_sem_);
+ std::lock_guard<Semaphore> lock(rowsets_flush_sem_);
return FlushUnlocked();
}
@@ -700,7 +700,7 @@ Status Tablet::FlushUnlocked() {
shared_ptr<MemRowSet> old_mrs;
{
// Create a new MRS with the latest schema.
- boost::lock_guard<rw_spinlock> lock(component_lock_);
+ std::lock_guard<rw_spinlock> lock(component_lock_);
RETURN_NOT_OK(ReplaceMemRowSetUnlocked(&input, &old_mrs));
}
@@ -717,12 +717,11 @@ Status Tablet::ReplaceMemRowSetUnlocked(RowSetsInCompaction *compaction,
*old_ms = components_->memrowset;
// Mark the memrowset rowset as locked, so compactions won't consider it
// for inclusion in any concurrent compactions.
- shared_ptr<boost::mutex::scoped_try_lock> ms_lock(
- new boost::mutex::scoped_try_lock(*((*old_ms)->compact_flush_lock())));
- CHECK(ms_lock->owns_lock());
+ std::unique_lock<std::mutex> ms_lock(*(*old_ms)->compact_flush_lock(), std::try_to_lock);
+ CHECK(ms_lock.owns_lock());
// Add to compaction.
- compaction->AddRowSet(*old_ms, ms_lock);
+ compaction->AddRowSet(*old_ms, std::move(ms_lock));
shared_ptr<MemRowSet> new_mrs(new MemRowSet(next_mrs_id_++, *schema(), log_anchor_registry_.get(),
mem_tracker_));
@@ -813,7 +812,7 @@ Status Tablet::AlterSchema(AlterSchemaTransactionState *tx_state) {
// Prevent any concurrent flushes. Otherwise, we run into issues where
// we have an MRS in the rowset tree, and we can't alter its schema
// in-place.
- boost::lock_guard<Semaphore> lock(rowsets_flush_sem_);
+ std::lock_guard<Semaphore> lock(rowsets_flush_sem_);
// If the current version >= new version, there is nothing to do.
bool same_schema = schema()->Equals(*tx_state->schema());
@@ -856,7 +855,7 @@ Status Tablet::RewindSchemaForBootstrap(const Schema& new_schema,
metadata_->SetSchema(new_schema, schema_version);
{
- boost::lock_guard<rw_spinlock> lock(component_lock_);
+ std::lock_guard<rw_spinlock> lock(component_lock_);
shared_ptr<MemRowSet> old_mrs = components_->memrowset;
shared_ptr<RowSetTree> old_rowsets = components_->rowsets;
@@ -914,7 +913,7 @@ CompactRowSetsOp::CompactRowSetsOp(Tablet* tablet)
}
void CompactRowSetsOp::UpdateStats(MaintenanceOpStats* stats) {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
// Any operation that changes the on-disk row layout invalidates the
// cached stats.
@@ -938,7 +937,7 @@ void CompactRowSetsOp::UpdateStats(MaintenanceOpStats* stats) {
}
bool CompactRowSetsOp::Prepare() {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
// Invalidate the cached stats so that another section of the tablet can
// be compacted concurrently.
//
@@ -978,7 +977,7 @@ MinorDeltaCompactionOp::MinorDeltaCompactionOp(Tablet* tablet)
}
void MinorDeltaCompactionOp::UpdateStats(MaintenanceOpStats* stats) {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
// Any operation that changes the number of REDO files invalidates the
// cached stats.
@@ -1012,7 +1011,7 @@ void MinorDeltaCompactionOp::UpdateStats(MaintenanceOpStats* stats) {
}
bool MinorDeltaCompactionOp::Prepare() {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
// Invalidate the cached stats so that another rowset in the tablet can
// be delta compacted concurrently.
//
@@ -1050,7 +1049,7 @@ MajorDeltaCompactionOp::MajorDeltaCompactionOp(Tablet* tablet)
}
void MajorDeltaCompactionOp::UpdateStats(MaintenanceOpStats* stats) {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
// Any operation that changes the size of the on-disk data invalidates the
// cached stats.
@@ -1088,7 +1087,7 @@ void MajorDeltaCompactionOp::UpdateStats(MaintenanceOpStats* stats) {
}
bool MajorDeltaCompactionOp::Prepare() {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
// Invalidate the cached stats so that another rowset in the tablet can
// be delta compacted concurrently.
//
@@ -1126,7 +1125,7 @@ Status Tablet::PickRowSetsToCompact(RowSetsInCompaction *picked,
rowsets_copy = components_->rowsets;
}
- boost::lock_guard<boost::mutex> compact_lock(compact_select_lock_);
+ std::lock_guard<std::mutex> compact_lock(compact_select_lock_);
CHECK_EQ(picked->num_rowsets(), 0);
unordered_set<RowSet*> picked_set;
@@ -1156,14 +1155,13 @@ Status Tablet::PickRowSetsToCompact(RowSetsInCompaction *picked,
// compaction from selecting this same rowset, and also ensures that
// we don't select a rowset which is currently in the middle of being
// flushed.
- shared_ptr<boost::mutex::scoped_try_lock> lock(
- new boost::mutex::scoped_try_lock(*rs->compact_flush_lock()));
- CHECK(lock->owns_lock()) << rs->ToString() << " appeared available for "
+ std::unique_lock<std::mutex> lock(*rs->compact_flush_lock(), std::try_to_lock);
+ CHECK(lock.owns_lock()) << rs->ToString() << " appeared available for "
"compaction when inputs were selected, but was unable to lock its "
"compact_flush_lock to prepare for compaction.";
// Push the lock on our scoped list, so we unlock when done.
- picked->AddRowSet(rs, lock);
+ picked->AddRowSet(rs, std::move(lock));
}
// When we iterated through the current rowsets, we should have found all of the
@@ -1332,7 +1330,7 @@ Status Tablet::DoCompactionOrFlush(const RowSetsInCompaction &input, int64_t mrs
TRACE_EVENT0("tablet", "Swapping DuplicatingRowSet");
// Taking component_lock_ in write mode ensures that no new transactions
// can StartApplying() (or snapshot components_) during this block.
- boost::lock_guard<rw_spinlock> lock(component_lock_);
+ std::lock_guard<rw_spinlock> lock(component_lock_);
AtomicSwapRowSetsUnlocked(input.rowsets(), { inprogress_rowset });
// NOTE: transactions may *commit* in between these two lines.
@@ -1478,7 +1476,7 @@ void Tablet::UpdateCompactionStats(MaintenanceOpStats* stats) {
}
{
- boost::lock_guard<boost::mutex> compact_lock(compact_select_lock_);
+ std::lock_guard<std::mutex> compact_lock(compact_select_lock_);
WARN_NOT_OK(compaction_policy_->PickRowSets(*rowsets_copy, &picked_set_ignored, &quality, NULL),
Substitute("Couldn't determine compaction quality for $0", tablet_id()));
}
@@ -1723,17 +1721,17 @@ Status Tablet::CompactWorstDeltas(RowSet::DeltaCompactionType type) {
CHECK_EQ(state_, kOpen);
shared_ptr<RowSet> rs;
// We're required to grab the rowset's compact_flush_lock under the compact_select_lock_.
- shared_ptr<boost::mutex::scoped_try_lock> lock;
+ std::unique_lock<std::mutex> lock;
double perf_improv;
{
// We only want to keep the selection lock during the time we look at rowsets to compact.
// The returned rowset is guaranteed to be available to lock since locking must be done
// under this lock.
- boost::lock_guard<boost::mutex> compact_lock(compact_select_lock_);
+ std::lock_guard<std::mutex> compact_lock(compact_select_lock_);
perf_improv = GetPerfImprovementForBestDeltaCompactUnlocked(type, &rs);
if (rs) {
- lock.reset(new boost::mutex::scoped_try_lock(*rs->compact_flush_lock()));
- CHECK(lock->owns_lock());
+ lock = std::unique_lock<std::mutex>(*rs->compact_flush_lock(), std::try_to_lock);
+ CHECK(lock.owns_lock());
} else {
return Status::OK();
}
@@ -1754,13 +1752,13 @@ Status Tablet::CompactWorstDeltas(RowSet::DeltaCompactionType type) {
double Tablet::GetPerfImprovementForBestDeltaCompact(RowSet::DeltaCompactionType type,
shared_ptr<RowSet>* rs) const {
- boost::lock_guard<boost::mutex> compact_lock(compact_select_lock_);
+ std::lock_guard<std::mutex> compact_lock(compact_select_lock_);
return GetPerfImprovementForBestDeltaCompactUnlocked(type, rs);
}
double Tablet::GetPerfImprovementForBestDeltaCompactUnlocked(RowSet::DeltaCompactionType type,
shared_ptr<RowSet>* rs) const {
- boost::mutex::scoped_try_lock cs_lock(compact_select_lock_);
+ std::unique_lock<std::mutex> cs_lock(compact_select_lock_, std::try_to_lock);
DCHECK(!cs_lock.owns_lock());
scoped_refptr<TabletComponents> comps;
GetComponents(&comps);
@@ -1793,7 +1791,7 @@ void Tablet::PrintRSLayout(ostream* o) {
boost::shared_lock<rw_spinlock> lock(component_lock_);
rowsets_copy = components_->rowsets;
}
- boost::lock_guard<boost::mutex> compact_lock(compact_select_lock_);
+ std::lock_guard<std::mutex> compact_lock(compact_select_lock_);
// Run the compaction policy in order to get its log and highlight those
// rowsets which would be compacted next.
vector<string> log;
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/tablet/tablet.h
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/tablet.h b/src/kudu/tablet/tablet.h
index 58175af..c5c666b 100644
--- a/src/kudu/tablet/tablet.h
+++ b/src/kudu/tablet/tablet.h
@@ -17,14 +17,14 @@
#ifndef KUDU_TABLET_TABLET_H
#define KUDU_TABLET_TABLET_H
+#include <boost/thread/shared_mutex.hpp>
#include <iosfwd>
#include <map>
#include <memory>
+#include <mutex>
#include <string>
#include <vector>
-#include <boost/thread/shared_mutex.hpp>
-
#include "kudu/common/iterator.h"
#include "kudu/common/schema.h"
#include "kudu/gutil/atomicops.h"
@@ -555,7 +555,7 @@ class Tablet {
// Lock protecting the selection of rowsets for compaction.
// Only one thread may run the compaction selection algorithm at a time
// so that they don't both try to select the same rowset.
- mutable boost::mutex compact_select_lock_;
+ mutable std::mutex compact_select_lock_;
// We take this lock when flushing the tablet's rowsets in Tablet::Flush. We
// don't want to have two flushes in progress at once, in case the one which
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/tablet/tablet_bootstrap.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/tablet_bootstrap.cc b/src/kudu/tablet/tablet_bootstrap.cc
index ab4422a..6c26f65 100644
--- a/src/kudu/tablet/tablet_bootstrap.cc
+++ b/src/kudu/tablet/tablet_bootstrap.cc
@@ -72,7 +72,6 @@ DECLARE_int32(max_clock_sync_error_usec);
namespace kudu {
namespace tablet {
-using boost::shared_lock;
using consensus::ALTER_SCHEMA_OP;
using consensus::CHANGE_CONFIG_OP;
using consensus::ChangeConfigRecordPB;
@@ -376,7 +375,7 @@ TabletStatusListener::~TabletStatusListener() {
void TabletStatusListener::StatusMessage(const string& status) {
LOG(INFO) << "T " << tablet_id() << " P " << meta_->fs_manager()->uuid() << ": "
<< status;
- boost::lock_guard<boost::shared_mutex> l(lock_);
+ std::lock_guard<boost::shared_mutex> l(lock_);
last_status_ = status;
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/tablet/tablet_metadata.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/tablet_metadata.cc b/src/kudu/tablet/tablet_metadata.cc
index ef4c8d2..e484471 100644
--- a/src/kudu/tablet/tablet_metadata.cc
+++ b/src/kudu/tablet/tablet_metadata.cc
@@ -18,9 +18,9 @@
#include "kudu/tablet/tablet_metadata.h"
#include <algorithm>
-#include <gflags/gflags.h>
#include <boost/optional.hpp>
-#include <boost/thread/locks.hpp>
+#include <gflags/gflags.h>
+#include <mutex>
#include <string>
#include "kudu/common/wire_protocol.h"
@@ -164,7 +164,7 @@ Status TabletMetadata::DeleteTabletData(TabletDataState delete_type,
// We also set the state in our persisted metadata to indicate that
// we have been deleted.
{
- boost::lock_guard<LockType> l(data_lock_);
+ std::lock_guard<LockType> l(data_lock_);
for (const shared_ptr<RowSetMetadata>& rsmd : rowsets_) {
AddOrphanedBlocksUnlocked(rsmd->GetAllBlocks());
}
@@ -187,7 +187,7 @@ Status TabletMetadata::DeleteTabletData(TabletDataState delete_type,
}
Status TabletMetadata::DeleteSuperBlock() {
- boost::lock_guard<LockType> l(data_lock_);
+ std::lock_guard<LockType> l(data_lock_);
if (!orphaned_blocks_.empty()) {
return Status::InvalidArgument("The metadata for tablet " + tablet_id_ +
" still references orphaned blocks. "
@@ -271,7 +271,7 @@ Status TabletMetadata::LoadFromSuperBlock(const TabletSuperBlockPB& superblock)
<< superblock.DebugString();
{
- boost::lock_guard<LockType> l(data_lock_);
+ std::lock_guard<LockType> l(data_lock_);
// Verify that the tablet id matches with the one in the protobuf
if (superblock.tablet_id() != tablet_id_) {
@@ -348,14 +348,14 @@ Status TabletMetadata::UpdateAndFlush(const RowSetMetadataIds& to_remove,
const RowSetMetadataVector& to_add,
int64_t last_durable_mrs_id) {
{
- boost::lock_guard<LockType> l(data_lock_);
+ std::lock_guard<LockType> l(data_lock_);
RETURN_NOT_OK(UpdateUnlocked(to_remove, to_add, last_durable_mrs_id));
}
return Flush();
}
void TabletMetadata::AddOrphanedBlocks(const vector<BlockId>& blocks) {
- boost::lock_guard<LockType> l(data_lock_);
+ std::lock_guard<LockType> l(data_lock_);
AddOrphanedBlocksUnlocked(blocks);
}
@@ -388,7 +388,7 @@ void TabletMetadata::DeleteOrphanedBlocks(const vector<BlockId>& blocks) {
// Remove the successfully-deleted blocks from the set.
{
- boost::lock_guard<LockType> l(data_lock_);
+ std::lock_guard<LockType> l(data_lock_);
for (const BlockId& b : deleted) {
orphaned_blocks_.erase(b);
}
@@ -396,14 +396,14 @@ void TabletMetadata::DeleteOrphanedBlocks(const vector<BlockId>& blocks) {
}
void TabletMetadata::PinFlush() {
- boost::lock_guard<LockType> l(data_lock_);
+ std::lock_guard<LockType> l(data_lock_);
CHECK_GE(num_flush_pins_, 0);
num_flush_pins_++;
VLOG(1) << "Number of flush pins: " << num_flush_pins_;
}
Status TabletMetadata::UnPinFlush() {
- boost::unique_lock<LockType> l(data_lock_);
+ std::unique_lock<LockType> l(data_lock_);
CHECK_GT(num_flush_pins_, 0);
num_flush_pins_--;
if (needs_flush_) {
@@ -421,7 +421,7 @@ Status TabletMetadata::Flush() {
vector<BlockId> orphaned;
TabletSuperBlockPB pb;
{
- boost::lock_guard<LockType> l(data_lock_);
+ std::lock_guard<LockType> l(data_lock_);
CHECK_GE(num_flush_pins_, 0);
if (num_flush_pins_ > 0) {
needs_flush_ = true;
@@ -519,7 +519,7 @@ Status TabletMetadata::ReadSuperBlockFromDisk(TabletSuperBlockPB* superblock) co
Status TabletMetadata::ToSuperBlock(TabletSuperBlockPB* super_block) const {
// acquire the lock so that rowsets_ doesn't get changed until we're finished.
- boost::lock_guard<LockType> l(data_lock_);
+ std::lock_guard<LockType> l(data_lock_);
return ToSuperBlockUnlocked(super_block, rowsets_);
}
@@ -576,7 +576,7 @@ const RowSetMetadata *TabletMetadata::GetRowSetForTests(int64_t id) const {
}
RowSetMetadata *TabletMetadata::GetRowSetForTests(int64_t id) {
- boost::lock_guard<LockType> l(data_lock_);
+ std::lock_guard<LockType> l(data_lock_);
for (const shared_ptr<RowSetMetadata>& rowset_meta : rowsets_) {
if (rowset_meta->id() == id) {
return rowset_meta.get();
@@ -587,7 +587,7 @@ RowSetMetadata *TabletMetadata::GetRowSetForTests(int64_t id) {
void TabletMetadata::SetSchema(const Schema& schema, uint32_t version) {
gscoped_ptr<Schema> new_schema(new Schema(schema));
- boost::lock_guard<LockType> l(data_lock_);
+ std::lock_guard<LockType> l(data_lock_);
SetSchemaUnlocked(std::move(new_schema), version);
}
@@ -606,24 +606,24 @@ void TabletMetadata::SetSchemaUnlocked(gscoped_ptr<Schema> new_schema, uint32_t
}
void TabletMetadata::SetTableName(const string& table_name) {
- boost::lock_guard<LockType> l(data_lock_);
+ std::lock_guard<LockType> l(data_lock_);
table_name_ = table_name;
}
string TabletMetadata::table_name() const {
- boost::lock_guard<LockType> l(data_lock_);
+ std::lock_guard<LockType> l(data_lock_);
DCHECK_NE(state_, kNotLoadedYet);
return table_name_;
}
uint32_t TabletMetadata::schema_version() const {
- boost::lock_guard<LockType> l(data_lock_);
+ std::lock_guard<LockType> l(data_lock_);
DCHECK_NE(state_, kNotLoadedYet);
return schema_version_;
}
void TabletMetadata::set_tablet_data_state(TabletDataState state) {
- boost::lock_guard<LockType> l(data_lock_);
+ std::lock_guard<LockType> l(data_lock_);
tablet_data_state_ = state;
}
@@ -632,7 +632,7 @@ string TabletMetadata::LogPrefix() const {
}
TabletDataState TabletMetadata::tablet_data_state() const {
- boost::lock_guard<LockType> l(data_lock_);
+ std::lock_guard<LockType> l(data_lock_);
return tablet_data_state_;
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/tablet/tablet_peer.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/tablet_peer.cc b/src/kudu/tablet/tablet_peer.cc
index 25a72d8..47aefc8 100644
--- a/src/kudu/tablet/tablet_peer.cc
+++ b/src/kudu/tablet/tablet_peer.cc
@@ -18,12 +18,12 @@
#include "kudu/tablet/tablet_peer.h"
#include <algorithm>
+#include <gflags/gflags.h>
+#include <mutex>
#include <string>
#include <utility>
#include <vector>
-#include <gflags/gflags.h>
-
#include "kudu/consensus/consensus.h"
#include "kudu/consensus/consensus_meta.h"
#include "kudu/consensus/local_consensus.h"
@@ -113,7 +113,7 @@ TabletPeer::TabletPeer(const scoped_refptr<TabletMetadata>& meta,
mark_dirty_clbk_(std::move(mark_dirty_clbk)) {}
TabletPeer::~TabletPeer() {
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
// We should either have called Shutdown(), or we should have never called
// Init().
CHECK(!tablet_)
@@ -139,7 +139,7 @@ Status TabletPeer::Init(const shared_ptr<Tablet>& tablet,
METRIC_op_prepare_run_time.Instantiate(metric_entity));
{
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
CHECK_EQ(BOOTSTRAPPING, state_);
tablet_ = tablet;
clock_ = clock;
@@ -197,7 +197,7 @@ Status TabletPeer::Start(const ConsensusBootstrapInfo& bootstrap_info) {
RETURN_NOT_OK(consensus_->Start(bootstrap_info));
{
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
CHECK_EQ(state_, BOOTSTRAPPING);
state_ = RUNNING;
}
@@ -261,7 +261,7 @@ void TabletPeer::Shutdown() {
// Only mark the peer as SHUTDOWN when all other components have shut down.
{
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
// Release mem tracker resources.
consensus_.reset();
tablet_.reset();
@@ -272,7 +272,7 @@ void TabletPeer::Shutdown() {
void TabletPeer::WaitUntilShutdown() {
while (true) {
{
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
if (state_ == SHUTDOWN) {
return;
}
@@ -283,7 +283,7 @@ void TabletPeer::WaitUntilShutdown() {
Status TabletPeer::CheckRunning() const {
{
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
if (state_ != RUNNING) {
return Status::IllegalState(Substitute("The tablet is not in a running state: $0",
TabletStatePB_Name(state_)));
@@ -301,7 +301,7 @@ Status TabletPeer::WaitUntilConsensusRunning(const MonoDelta& timeout) {
bool has_consensus = false;
TabletStatePB cached_state;
{
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
cached_state = state_;
if (consensus_) {
has_consensus = true; // consensus_ is a set-once object.
@@ -348,7 +348,7 @@ Status TabletPeer::SubmitAlterSchema(unique_ptr<AlterSchemaTransactionState> sta
}
void TabletPeer::GetTabletStatusPB(TabletStatusPB* status_pb_out) const {
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
DCHECK(status_pb_out != nullptr);
DCHECK(status_listener_.get() != nullptr);
status_pb_out->set_tablet_id(status_listener_->tablet_id());
@@ -378,7 +378,7 @@ Status TabletPeer::RunLogGC() {
}
string TabletPeer::HumanReadableState() const {
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
TabletDataState data_state = meta_->tablet_data_state();
// If failed, any number of things could have gone wrong.
if (state_ == FAILED) {
@@ -479,7 +479,7 @@ Status TabletPeer::GetGCableDataSize(int64_t* retention_size) const {
Status TabletPeer::StartReplicaTransaction(const scoped_refptr<ConsensusRound>& round) {
{
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
if (state_ != RUNNING && state_ != BOOTSTRAPPING) {
return Status::IllegalState(TabletStatePB_Name(state_));
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/tablet/tablet_peer.h
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/tablet_peer.h b/src/kudu/tablet/tablet_peer.h
index 25a9ec6..20f03e3 100644
--- a/src/kudu/tablet/tablet_peer.h
+++ b/src/kudu/tablet/tablet_peer.h
@@ -20,6 +20,7 @@
#include <map>
#include <memory>
+#include <mutex>
#include <string>
#include <vector>
@@ -122,27 +123,27 @@ class TabletPeer : public RefCountedThreadSafe<TabletPeer>,
const scoped_refptr<consensus::ConsensusRound>& round) OVERRIDE;
consensus::Consensus* consensus() {
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
return consensus_.get();
}
scoped_refptr<consensus::Consensus> shared_consensus() const {
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
return consensus_;
}
Tablet* tablet() const {
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
return tablet_.get();
}
std::shared_ptr<Tablet> shared_tablet() const {
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
return tablet_;
}
const TabletStatePB state() const {
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
return state_;
}
@@ -160,7 +161,7 @@ class TabletPeer : public RefCountedThreadSafe<TabletPeer>,
// Sets the tablet to a BOOTSTRAPPING state, indicating it is starting up.
void SetBootstrapping() {
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
CHECK_EQ(NOT_STARTED, state_);
state_ = BOOTSTRAPPING;
}
@@ -168,14 +169,14 @@ class TabletPeer : public RefCountedThreadSafe<TabletPeer>,
// sets the tablet state to FAILED additionally setting the error to the provided
// one.
void SetFailed(const Status& error) {
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
state_ = FAILED;
error_ = error;
}
// Returns the error that occurred, when state is FAILED.
Status error() const {
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
return error_;
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/tablet/tablet_peer_mm_ops.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/tablet_peer_mm_ops.cc b/src/kudu/tablet/tablet_peer_mm_ops.cc
index c8bc920..a1fc4df 100644
--- a/src/kudu/tablet/tablet_peer_mm_ops.cc
+++ b/src/kudu/tablet/tablet_peer_mm_ops.cc
@@ -18,11 +18,11 @@
#include "kudu/tablet/tablet_peer_mm_ops.h"
#include <algorithm>
+#include <gflags/gflags.h>
#include <map>
+#include <mutex>
#include <string>
-#include <gflags/gflags.h>
-
#include "kudu/gutil/strings/substitute.h"
#include "kudu/tablet/maintenance_manager.h"
#include "kudu/tablet/tablet_metrics.h"
@@ -90,7 +90,7 @@ void FlushOpPerfImprovementPolicy::SetPerfImprovementForFlush(MaintenanceOpStats
//
void FlushMRSOp::UpdateStats(MaintenanceOpStats* stats) {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
map<int64_t, int64_t> max_idx_to_segment_size;
if (tablet_peer_->tablet()->MemRowSetEmpty() ||
@@ -99,8 +99,7 @@ void FlushMRSOp::UpdateStats(MaintenanceOpStats* stats) {
}
{
- boost::unique_lock<Semaphore> lock(tablet_peer_->tablet()->rowsets_flush_sem_,
- boost::defer_lock);
+ std::unique_lock<Semaphore> lock(tablet_peer_->tablet()->rowsets_flush_sem_, std::defer_lock);
stats->set_runnable(lock.try_lock());
}
@@ -129,7 +128,7 @@ void FlushMRSOp::Perform() {
Substitute("FlushMRS failed on $0", tablet_peer_->tablet_id()));
{
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
time_since_flush_.start();
}
tablet_peer_->tablet()->rowsets_flush_sem_.unlock();
@@ -148,7 +147,7 @@ scoped_refptr<AtomicGauge<uint32_t> > FlushMRSOp::RunningGauge() const {
//
void FlushDeltaMemStoresOp::UpdateStats(MaintenanceOpStats* stats) {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
int64_t dms_size;
int64_t retention_size;
map<int64_t, int64_t> max_idx_to_segment_size;
@@ -178,7 +177,7 @@ void FlushDeltaMemStoresOp::Perform() {
Substitute("Failed to flush DMS on $0",
tablet_peer_->tablet()->tablet_id()));
{
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
time_since_flush_.start();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/tablet/transactions/transaction_driver.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/transactions/transaction_driver.cc b/src/kudu/tablet/transactions/transaction_driver.cc
index cf065cf..30ec10e 100644
--- a/src/kudu/tablet/transactions/transaction_driver.cc
+++ b/src/kudu/tablet/transactions/transaction_driver.cc
@@ -17,6 +17,8 @@
#include "kudu/tablet/transactions/transaction_driver.h"
+#include <mutex>
+
#include "kudu/consensus/consensus.h"
#include "kudu/gutil/strings/strcat.h"
#include "kudu/tablet/tablet_peer.h"
@@ -72,7 +74,7 @@ Status TransactionDriver::Init(gscoped_ptr<Transaction> transaction,
transaction_ = std::move(transaction);
if (type == consensus::REPLICA) {
- boost::lock_guard<simple_spinlock> lock(opid_lock_);
+ std::lock_guard<simple_spinlock> lock(opid_lock_);
op_id_copy_ = transaction_->state()->op_id();
DCHECK(op_id_copy_.IsInitialized());
replication_state_ = REPLICATING;
@@ -95,7 +97,7 @@ Status TransactionDriver::Init(gscoped_ptr<Transaction> transaction,
}
consensus::OpId TransactionDriver::GetOpId() {
- boost::lock_guard<simple_spinlock> lock(opid_lock_);
+ std::lock_guard<simple_spinlock> lock(opid_lock_);
return op_id_copy_;
}
@@ -112,7 +114,7 @@ Transaction::TransactionType TransactionDriver::tx_type() const {
}
string TransactionDriver::ToString() const {
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
return ToStringUnlocked();
}
@@ -176,7 +178,7 @@ Status TransactionDriver::PrepareAndStart() {
// phase.
ReplicationState repl_state_copy;
{
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
CHECK_EQ(prepare_state_, NOT_PREPARED);
prepare_state_ = PREPARED;
repl_state_copy = replication_state_;
@@ -194,14 +196,14 @@ Status TransactionDriver::PrepareAndStart() {
// Trigger the consensus replication.
{
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
replication_state_ = REPLICATING;
replication_start_time_ = MonoTime::Now(MonoTime::FINE);
}
Status s = consensus_->Replicate(mutable_state()->consensus_round());
if (PREDICT_FALSE(!s.ok())) {
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
CHECK_EQ(replication_state_, REPLICATING);
transaction_status_ = s;
replication_state_ = REPLICATION_FAILED;
@@ -237,7 +239,7 @@ void TransactionDriver::HandleFailure(const Status& s) {
ReplicationState repl_state_copy;
{
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
transaction_status_ = s;
repl_state_copy = replication_state_;
}
@@ -271,7 +273,7 @@ void TransactionDriver::ReplicationFinished(const Status& status) {
ADOPT_TRACE(trace());
{
- boost::lock_guard<simple_spinlock> op_id_lock(opid_lock_);
+ std::lock_guard<simple_spinlock> op_id_lock(opid_lock_);
// TODO: it's a bit silly that we have three copies of the opid:
// one here, one in ConsensusRound, and one in TransactionState.
@@ -283,7 +285,7 @@ void TransactionDriver::ReplicationFinished(const Status& status) {
MonoDelta replication_duration;
PrepareState prepare_state_copy;
{
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
CHECK_EQ(replication_state_, REPLICATING);
if (status.ok()) {
replication_state_ = REPLICATED;
@@ -315,7 +317,7 @@ void TransactionDriver::Abort(const Status& status) {
ReplicationState repl_state_copy;
{
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
repl_state_copy = replication_state_;
transaction_status_ = status;
}
@@ -332,7 +334,7 @@ void TransactionDriver::Abort(const Status& status) {
Status TransactionDriver::ApplyAsync() {
{
- boost::unique_lock<simple_spinlock> lock(lock_);
+ std::unique_lock<simple_spinlock> lock(lock_);
DCHECK_EQ(prepare_state_, PREPARED);
if (transaction_status_.ok()) {
DCHECK_EQ(replication_state_, REPLICATED);
@@ -361,7 +363,7 @@ void TransactionDriver::ApplyTask() {
ADOPT_TRACE(trace());
{
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
DCHECK_EQ(replication_state_, REPLICATED);
DCHECK_EQ(prepare_state_, PREPARED);
}
@@ -427,7 +429,7 @@ void TransactionDriver::Finalize() {
// TODO: this is an ugly hack so that the Release() call doesn't delete the
// object while we still hold the lock.
scoped_refptr<TransactionDriver> ref(this);
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
transaction_->Finish(Transaction::COMMITTED);
mutable_state()->completion_callback()->TransactionCompleted();
txn_tracker_->Release(this);
@@ -473,7 +475,7 @@ std::string TransactionDriver::LogPrefix() const {
string ts_string;
{
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
repl_state_copy = replication_state_;
prep_state_copy = prepare_state_;
ts_string = state()->has_timestamp() ? state()->timestamp().ToString() : "No timestamp";
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/tablet/transactions/write_transaction.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/transactions/write_transaction.cc b/src/kudu/tablet/transactions/write_transaction.cc
index fce343a..e7a6ba5 100644
--- a/src/kudu/tablet/transactions/write_transaction.cc
+++ b/src/kudu/tablet/transactions/write_transaction.cc
@@ -45,7 +45,6 @@ TAG_FLAG(tablet_inject_latency_on_apply_write_txn_ms, runtime);
namespace kudu {
namespace tablet {
-using boost::bind;
using consensus::ReplicateMsg;
using consensus::CommitMsg;
using consensus::DriverType;
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/tserver/scanners.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tserver/scanners.cc b/src/kudu/tserver/scanners.cc
index 11ac9b3..13c588f 100644
--- a/src/kudu/tserver/scanners.cc
+++ b/src/kudu/tserver/scanners.cc
@@ -17,8 +17,9 @@
#include "kudu/tserver/scanners.h"
#include <boost/bind.hpp>
-#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
#include <gflags/gflags.h>
+#include <mutex>
#include "kudu/common/iterator.h"
#include "kudu/common/scan_spec.h"
@@ -116,7 +117,7 @@ void ScannerManager::NewScanner(const scoped_refptr<TabletPeer>& tablet_peer,
scanner->reset(new Scanner(id, tablet_peer, requestor_string, metrics_.get()));
ScannerMapStripe& stripe = GetStripeByScannerId(id);
- boost::lock_guard<boost::shared_mutex> l(stripe.lock_);
+ std::lock_guard<boost::shared_mutex> l(stripe.lock_);
success = InsertIfNotPresent(&stripe.scanners_by_id_, id, *scanner);
}
}
@@ -129,7 +130,7 @@ bool ScannerManager::LookupScanner(const string& scanner_id, SharedScanner* scan
bool ScannerManager::UnregisterScanner(const string& scanner_id) {
ScannerMapStripe& stripe = GetStripeByScannerId(scanner_id);
- boost::lock_guard<boost::shared_mutex> l(stripe.lock_);
+ std::lock_guard<boost::shared_mutex> l(stripe.lock_);
return stripe.scanners_by_id_.erase(scanner_id) > 0;
}
@@ -155,7 +156,7 @@ void ScannerManager::RemoveExpiredScanners() {
MonoDelta scanner_ttl = MonoDelta::FromMilliseconds(FLAGS_scanner_ttl_ms);
for (ScannerMapStripe* stripe : scanner_maps_) {
- boost::lock_guard<boost::shared_mutex> l(stripe->lock_);
+ std::lock_guard<boost::shared_mutex> l(stripe->lock_);
for (auto it = stripe->scanners_by_id_.begin(); it != stripe->scanners_by_id_.end();) {
SharedScanner& scanner = it->second;
MonoDelta time_live =
@@ -197,13 +198,13 @@ Scanner::~Scanner() {
}
void Scanner::UpdateAccessTime() {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
last_access_time_ = MonoTime::Now(MonoTime::COARSE);
}
void Scanner::Init(gscoped_ptr<RowwiseIterator> iter,
gscoped_ptr<ScanSpec> spec) {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
CHECK(!iter_) << "Already initialized";
iter_.reset(iter.release());
spec_.reset(spec.release());
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/tserver/scanners.h
----------------------------------------------------------------------
diff --git a/src/kudu/tserver/scanners.h b/src/kudu/tserver/scanners.h
index aeab8b1..e114623 100644
--- a/src/kudu/tserver/scanners.h
+++ b/src/kudu/tserver/scanners.h
@@ -19,6 +19,7 @@
#include <boost/thread/shared_mutex.hpp>
#include <memory>
+#include <mutex>
#include <string>
#include <unordered_map>
#include <utility>
@@ -180,7 +181,7 @@ class Scanner {
// Once a Scanner is initialized, it is safe to assume that iter() and spec()
// return non-NULL for the lifetime of the Scanner object.
bool IsInitialized() const {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
return iter_ != NULL;
}
@@ -224,19 +225,19 @@ class Scanner {
// Returns the current call sequence ID of the scanner.
uint32_t call_seq_id() const {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
return call_seq_id_;
}
// Increments the call sequence ID.
void IncrementCallSeqId() {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
call_seq_id_ += 1;
}
// Return the delta from the last time this scan was updated to 'now'.
MonoDelta TimeSinceLastAccess(const MonoTime& now) const {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
return now.GetDeltaSince(last_access_time_);
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/tserver/ts_tablet_manager.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tserver/ts_tablet_manager.cc b/src/kudu/tserver/ts_tablet_manager.cc
index 1276135..fcd46e7 100644
--- a/src/kudu/tserver/ts_tablet_manager.cc
+++ b/src/kudu/tserver/ts_tablet_manager.cc
@@ -18,12 +18,12 @@
#include "kudu/tserver/ts_tablet_manager.h"
#include <algorithm>
+#include <boost/bind.hpp>
#include <boost/optional.hpp>
-#include <boost/thread/locks.hpp>
-#include <boost/thread/mutex.hpp>
#include <boost/thread/shared_mutex.hpp>
#include <glog/logging.h>
#include <memory>
+#include <mutex>
#include <string>
#include <vector>
@@ -205,7 +205,7 @@ Status TSTabletManager::Init() {
for (const scoped_refptr<TabletMetadata>& meta : metas) {
scoped_refptr<TransitionInProgressDeleter> deleter;
{
- boost::lock_guard<rw_spinlock> lock(lock_);
+ std::lock_guard<rw_spinlock> lock(lock_);
CHECK_OK(StartTabletStateTransitionUnlocked(meta->tablet_id(), "opening tablet", &deleter));
}
@@ -215,7 +215,7 @@ Status TSTabletManager::Init() {
}
{
- boost::lock_guard<rw_spinlock> lock(lock_);
+ std::lock_guard<rw_spinlock> lock(lock_);
state_ = MANAGER_RUNNING;
}
@@ -265,7 +265,7 @@ Status TSTabletManager::CreateNewTablet(const string& table_id,
{
// acquire the lock in exclusive mode as we'll add a entry to the
// transition_in_progress_ set if the lookup fails.
- boost::lock_guard<rw_spinlock> lock(lock_);
+ std::lock_guard<rw_spinlock> lock(lock_);
TRACE("Acquired tablet manager lock");
// Sanity check that the tablet isn't already registered.
@@ -354,7 +354,7 @@ Status TSTabletManager::StartRemoteBootstrap(
bool replacing_tablet = false;
scoped_refptr<TransitionInProgressDeleter> deleter;
{
- boost::lock_guard<rw_spinlock> lock(lock_);
+ std::lock_guard<rw_spinlock> lock(lock_);
if (LookupTabletUnlocked(tablet_id, &old_tablet_peer)) {
meta = old_tablet_peer->tablet_metadata();
replacing_tablet = true;
@@ -488,7 +488,7 @@ Status TSTabletManager::DeleteTablet(
{
// Acquire the lock in exclusive mode as we'll add a entry to the
// transition_in_progress_ map.
- boost::lock_guard<rw_spinlock> lock(lock_);
+ std::lock_guard<rw_spinlock> lock(lock_);
TRACE("Acquired tablet manager lock");
RETURN_NOT_OK(CheckRunningUnlocked(error_code));
@@ -552,7 +552,7 @@ Status TSTabletManager::DeleteTablet(
// We only remove DELETED tablets from the tablet map.
if (delete_type == TABLET_DATA_DELETED) {
- boost::lock_guard<rw_spinlock> lock(lock_);
+ std::lock_guard<rw_spinlock> lock(lock_);
RETURN_NOT_OK(CheckRunningUnlocked(error_code));
CHECK_EQ(1, tablet_map_.erase(tablet_id)) << tablet_id;
InsertOrDie(&perm_deleted_tablet_ids_, tablet_id);
@@ -701,7 +701,7 @@ void TSTabletManager::OpenTablet(const scoped_refptr<TabletMetadata>& meta,
void TSTabletManager::Shutdown() {
{
- boost::lock_guard<rw_spinlock> lock(lock_);
+ std::lock_guard<rw_spinlock> lock(lock_);
switch (state_) {
case MANAGER_QUIESCING: {
VLOG(1) << "Tablet manager shut down already in progress..";
@@ -740,7 +740,7 @@ void TSTabletManager::Shutdown() {
apply_pool_->Shutdown();
{
- boost::lock_guard<rw_spinlock> l(lock_);
+ std::lock_guard<rw_spinlock> l(lock_);
// We don't expect anyone else to be modifying the map after we start the
// shut down process.
CHECK_EQ(tablet_map_.size(), peers_to_shutdown.size())
@@ -754,7 +754,7 @@ void TSTabletManager::Shutdown() {
void TSTabletManager::RegisterTablet(const std::string& tablet_id,
const scoped_refptr<TabletPeer>& tablet_peer,
RegisterTabletPeerMode mode) {
- boost::lock_guard<rw_spinlock> lock(lock_);
+ std::lock_guard<rw_spinlock> lock(lock_);
// If we are replacing a tablet peer, we delete the existing one first.
if (mode == REPLACEMENT_PEER && tablet_map_.erase(tablet_id) != 1) {
LOG(FATAL) << "Unable to remove previous tablet peer " << tablet_id << ": not registered!";
@@ -806,7 +806,7 @@ void TSTabletManager::GetTabletPeers(vector<scoped_refptr<TabletPeer> >* tablet_
}
void TSTabletManager::MarkTabletDirty(const std::string& tablet_id, const std::string& reason) {
- boost::lock_guard<rw_spinlock> lock(lock_);
+ std::lock_guard<rw_spinlock> lock(lock_);
MarkDirtyUnlocked(tablet_id, reason);
}
@@ -903,7 +903,7 @@ void TSTabletManager::GenerateFullTabletReport(TabletReportPB* report) {
}
void TSTabletManager::MarkTabletReportAcknowledged(const TabletReportPB& report) {
- boost::lock_guard<rw_spinlock> l(lock_);
+ std::lock_guard<rw_spinlock> l(lock_);
int32_t acked_seq = report.sequence_number();
CHECK_LT(acked_seq, next_report_seq_);
@@ -1009,7 +1009,7 @@ TransitionInProgressDeleter::TransitionInProgressDeleter(
: in_progress_(map), lock_(lock), entry_(std::move(entry)) {}
TransitionInProgressDeleter::~TransitionInProgressDeleter() {
- boost::lock_guard<rw_spinlock> lock(*lock_);
+ std::lock_guard<rw_spinlock> lock(*lock_);
CHECK(in_progress_->erase(entry_));
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/tserver/ts_tablet_manager.h
----------------------------------------------------------------------
diff --git a/src/kudu/tserver/ts_tablet_manager.h b/src/kudu/tserver/ts_tablet_manager.h
index 9cdb830..5d5dbbf 100644
--- a/src/kudu/tserver/ts_tablet_manager.h
+++ b/src/kudu/tserver/ts_tablet_manager.h
@@ -18,7 +18,7 @@
#define KUDU_TSERVER_TS_TABLET_MANAGER_H
#include <boost/optional/optional_fwd.hpp>
-#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
#include <gtest/gtest_prod.h>
#include <memory>
#include <string>
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/twitter-demo/insert_consumer.cc
----------------------------------------------------------------------
diff --git a/src/kudu/twitter-demo/insert_consumer.cc b/src/kudu/twitter-demo/insert_consumer.cc
index 370b8cc..2371f7a 100644
--- a/src/kudu/twitter-demo/insert_consumer.cc
+++ b/src/kudu/twitter-demo/insert_consumer.cc
@@ -17,8 +17,8 @@
#include "kudu/twitter-demo/insert_consumer.h"
-#include <boost/thread/locks.hpp>
#include <glog/logging.h>
+#include <mutex>
#include <string>
#include <time.h>
#include <vector>
@@ -96,7 +96,7 @@ InsertConsumer::~InsertConsumer() {
}
void InsertConsumer::BatchFinished(const Status& s) {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
request_pending_ = false;
if (!s.ok()) {
bool overflow;
@@ -145,7 +145,7 @@ void InsertConsumer::ConsumeJSON(const Slice& json_slice) {
// instead of the manual batching here
bool do_flush = false;
{
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
if (!request_pending_) {
request_pending_ = true;
do_flush = true;
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/twitter-demo/twitter_streamer.cc
----------------------------------------------------------------------
diff --git a/src/kudu/twitter-demo/twitter_streamer.cc b/src/kudu/twitter-demo/twitter_streamer.cc
index d9bfcee..99a1cb0 100644
--- a/src/kudu/twitter-demo/twitter_streamer.cc
+++ b/src/kudu/twitter-demo/twitter_streamer.cc
@@ -17,10 +17,10 @@
#include "kudu/twitter-demo/twitter_streamer.h"
-#include <boost/thread/locks.hpp>
#include <curl/curl.h>
#include <gflags/gflags.h>
#include <glog/logging.h>
+#include <mutex>
#include <string.h>
#include <string>
#include <thread>
@@ -132,7 +132,7 @@ void TwitterStreamer::StreamThread() {
Status s = DoStreaming();
if (!s.ok()) {
LOG(ERROR) << "Streaming thread failed: " << s.ToString();
- boost::lock_guard<boost::mutex> l(lock_);
+ std::lock_guard<std::mutex> l(lock_);
stream_status_ = s;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/twitter-demo/twitter_streamer.h
----------------------------------------------------------------------
diff --git a/src/kudu/twitter-demo/twitter_streamer.h b/src/kudu/twitter-demo/twitter_streamer.h
index 6412fa5..df292bd 100644
--- a/src/kudu/twitter-demo/twitter_streamer.h
+++ b/src/kudu/twitter-demo/twitter_streamer.h
@@ -17,7 +17,7 @@
#ifndef KUDU_TWITTER_DEMO_TWITTER_STREAMER_H
#define KUDU_TWITTER_DEMO_TWITTER_STREAMER_H
-#include <boost/thread/mutex.hpp>
+#include <mutex>
#include <thread>
#include "kudu/util/faststring.h"
@@ -52,7 +52,7 @@ class TwitterStreamer {
size_t DataReceived(const Slice& data);
thread thread_;
- boost::mutex lock_;
+ std::mutex lock_;
Status stream_status_;
faststring recv_buf_;
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/util/boost_mutex_utils.h
----------------------------------------------------------------------
diff --git a/src/kudu/util/boost_mutex_utils.h b/src/kudu/util/boost_mutex_utils.h
index 41e475b..6f6390b 100644
--- a/src/kudu/util/boost_mutex_utils.h
+++ b/src/kudu/util/boost_mutex_utils.h
@@ -18,8 +18,8 @@
#define KUDU_BOOST_MUTEX_UTILS_H
-// Similar to boost::lock_guard except that it takes
-// a lock pointer, and checks against NULL. If the
+// Similar to std::lock_guard except that it takes
+// a lock pointer, and checks against nullptr. If the
// pointer is NULL, does nothing. Otherwise guards
// with the lock.
template<class LockType>
@@ -27,13 +27,13 @@ class lock_guard_maybe {
public:
explicit lock_guard_maybe(LockType *l) :
lock_(l) {
- if (l != NULL) {
+ if (l != nullptr) {
l->lock();
}
}
~lock_guard_maybe() {
- if (lock_ != NULL) {
+ if (lock_ != nullptr) {
lock_->unlock();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/util/locks.h
----------------------------------------------------------------------
diff --git a/src/kudu/util/locks.h b/src/kudu/util/locks.h
index 28b4092..423f533 100644
--- a/src/kudu/util/locks.h
+++ b/src/kudu/util/locks.h
@@ -231,7 +231,7 @@ class percpu_rwlock {
padded_lock *locks_;
};
-// Simpler version of boost::lock_guard. Only supports the basic object
+// Simpler version of std::lock_guard. Only supports the basic object
// lifecycle and defers any error checking to the underlying mutex.
template <typename Mutex>
class lock_guard {
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/util/mt-threadlocal-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/mt-threadlocal-test.cc b/src/kudu/util/mt-threadlocal-test.cc
index c3479ff..1d4d6b3 100644
--- a/src/kudu/util/mt-threadlocal-test.cc
+++ b/src/kudu/util/mt-threadlocal-test.cc
@@ -15,8 +15,8 @@
// specific language governing permissions and limitations
// under the License.
-#include <boost/thread/locks.hpp>
#include <glog/logging.h>
+#include <mutex>
#include <unordered_set>
#include "kudu/gutil/macros.h"
@@ -86,14 +86,14 @@ class Counter {
registry_(CHECK_NOTNULL(registry)),
val_(val) {
LOG(INFO) << "Counter::~Counter(): tid = " << tid_ << ", addr = " << this << ", val = " << val_;
- boost::lock_guard<RegistryLockType> reg_lock(*registry_->get_lock());
+ std::lock_guard<RegistryLockType> reg_lock(*registry_->get_lock());
CHECK(registry_->RegisterUnlocked(this));
}
~Counter() {
LOG(INFO) << "Counter::~Counter(): tid = " << tid_ << ", addr = " << this << ", val = " << val_;
- boost::lock_guard<RegistryLockType> reg_lock(*registry_->get_lock());
- boost::lock_guard<CounterLockType> self_lock(lock_);
+ std::lock_guard<RegistryLockType> reg_lock(*registry_->get_lock());
+ std::lock_guard<CounterLockType> self_lock(lock_);
LOG(INFO) << tid_ << ": deleting self from registry...";
CHECK(registry_->UnregisterUnlocked(this));
}
@@ -143,7 +143,7 @@ static void RegisterCounterAndLoopIncr(CounterRegistry* registry,
reader_ready->Wait();
// Now rock & roll on the counting loop.
for (int i = 0; i < kTargetCounterVal; i++) {
- boost::lock_guard<CounterLockType> l(*counter->get_lock());
+ std::lock_guard<CounterLockType> l(*counter->get_lock());
counter->IncrementUnlocked();
}
// Let the reader know we're ready for him to verify our counts.
@@ -157,11 +157,11 @@ static void RegisterCounterAndLoopIncr(CounterRegistry* registry,
static uint64_t Iterate(CounterRegistry* registry, int expected_counters) {
uint64_t sum = 0;
int seen_counters = 0;
- boost::lock_guard<RegistryLockType> l(*registry->get_lock());
+ std::lock_guard<RegistryLockType> l(*registry->get_lock());
for (Counter* counter : *registry->GetCountersUnlocked()) {
uint64_t value;
{
- boost::lock_guard<CounterLockType> l(*counter->get_lock());
+ std::lock_guard<CounterLockType> l(*counter->get_lock());
value = counter->GetValueUnlocked();
}
LOG(INFO) << "tid " << counter->tid() << " (counter " << counter << "): " << value;
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/util/oid_generator.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/oid_generator.cc b/src/kudu/util/oid_generator.cc
index 5c680b4..da7acd8 100644
--- a/src/kudu/util/oid_generator.cc
+++ b/src/kudu/util/oid_generator.cc
@@ -15,6 +15,7 @@
// specific language governing permissions and limitations
// under the License.
+#include <mutex>
#include <string>
#include "kudu/gutil/stringprintf.h"
@@ -23,7 +24,7 @@
namespace kudu {
string ObjectIdGenerator::Next() {
- lock_guard<LockType> l(&oid_lock_);
+ std::lock_guard<LockType> l(oid_lock_);
boost::uuids::uuid oid = oid_generator_();
const uint8_t *uuid = oid.data;
return StringPrintf("%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/util/rw_semaphore-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/rw_semaphore-test.cc b/src/kudu/util/rw_semaphore-test.cc
index 19324e9..8c0ddd3 100644
--- a/src/kudu/util/rw_semaphore-test.cc
+++ b/src/kudu/util/rw_semaphore-test.cc
@@ -15,8 +15,9 @@
// specific language governing permissions and limitations
// under the License.
-#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
#include <gtest/gtest.h>
+#include <mutex>
#include <thread>
#include <vector>
@@ -39,7 +40,7 @@ struct SharedState {
void Writer(SharedState* state) {
int i = 0;
while (true) {
- boost::lock_guard<rw_semaphore> l(state->sem);
+ std::lock_guard<rw_semaphore> l(state->sem);
state->int_var += (i++);
if (state->done) {
break;
@@ -77,7 +78,7 @@ TEST(RWSemaphoreTest, TestBasicOperation) {
// Signal them to stop.
{
- boost::lock_guard<rw_semaphore> l(s.sem);
+ std::lock_guard<rw_semaphore> l(s.sem);
s.done = true;
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/util/rwc_lock-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/rwc_lock-test.cc b/src/kudu/util/rwc_lock-test.cc
index e3959c0..99c8071 100644
--- a/src/kudu/util/rwc_lock-test.cc
+++ b/src/kudu/util/rwc_lock-test.cc
@@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.
-#include <boost/thread/locks.hpp>
+#include <mutex>
#include <string>
#include <thread>
#include <vector>
@@ -57,19 +57,19 @@ struct LockHoldersCount {
}
void AdjustReaders(int delta) {
- boost::lock_guard<simple_spinlock> l(lock);
+ std::lock_guard<simple_spinlock> l(lock);
num_readers += delta;
CheckInvariants();
}
void AdjustWriters(int delta) {
- boost::lock_guard<simple_spinlock> l(lock);
+ std::lock_guard<simple_spinlock> l(lock);
num_writers += delta;
CheckInvariants();
}
void AdjustCommitters(int delta) {
- boost::lock_guard<simple_spinlock> l(lock);
+ std::lock_guard<simple_spinlock> l(lock);
num_committers += delta;
CheckInvariants();
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/util/throttler.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/throttler.cc b/src/kudu/util/throttler.cc
index 0eb4e9c..6207bdb 100644
--- a/src/kudu/util/throttler.cc
+++ b/src/kudu/util/throttler.cc
@@ -17,6 +17,8 @@
#include "kudu/util/throttler.h"
+#include <mutex>
+
namespace kudu {
Throttler::Throttler(MonoTime now, uint64_t op_rate, uint64_t byte_rate, double burst_factor) :
@@ -33,7 +35,7 @@ bool Throttler::Take(MonoTime now, uint64_t op, uint64_t byte) {
if (op_refill_ == 0 && byte_refill_ == 0) {
return true;
}
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
Refill(now);
if ((op_refill_ == 0 || op <= op_token_) &&
(byte_refill_ == 0 || byte <= byte_token_)) {
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/util/throttler.h
----------------------------------------------------------------------
diff --git a/src/kudu/util/throttler.h b/src/kudu/util/throttler.h
index 239778a..7be7ba1 100644
--- a/src/kudu/util/throttler.h
+++ b/src/kudu/util/throttler.h
@@ -19,8 +19,6 @@
#include <algorithm>
-#include <boost/thread/locks.hpp>
-
#include "kudu/gutil/macros.h"
#include "kudu/util/locks.h"
#include "kudu/util/monotime.h"
[4/5] incubator-kudu git commit: Replace kudu::{lock_guard,
unique_lock} with std lib equivalents
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/tablet/transactions/write_transaction.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/transactions/write_transaction.cc b/src/kudu/tablet/transactions/write_transaction.cc
index e7a6ba5..289e15c 100644
--- a/src/kudu/tablet/transactions/write_transaction.cc
+++ b/src/kudu/tablet/transactions/write_transaction.cc
@@ -327,7 +327,7 @@ void WriteTransactionState::Reset() {
}
void WriteTransactionState::ResetRpcFields() {
- lock_guard<simple_spinlock> l(&txn_state_lock_);
+ std::lock_guard<simple_spinlock> l(txn_state_lock_);
request_ = nullptr;
response_ = nullptr;
STLDeleteElements(&row_ops_);
@@ -346,7 +346,7 @@ string WriteTransactionState::ToString() const {
// user data escaping into the log. See KUDU-387.
string row_ops_str = "[";
{
- lock_guard<simple_spinlock> l(&txn_state_lock_);
+ std::lock_guard<simple_spinlock> l(txn_state_lock_);
const size_t kMaxToStringify = 3;
for (int i = 0; i < std::min(row_ops_.size(), kMaxToStringify); i++) {
if (i > 0) {
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/tablet/transactions/write_transaction.h
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/transactions/write_transaction.h b/src/kudu/tablet/transactions/write_transaction.h
index 1975fe5..0328ae0 100644
--- a/src/kudu/tablet/transactions/write_transaction.h
+++ b/src/kudu/tablet/transactions/write_transaction.h
@@ -18,6 +18,7 @@
#ifndef KUDU_TABLET_WRITE_TRANSACTION_H_
#define KUDU_TABLET_WRITE_TRANSACTION_H_
+#include <mutex>
#include <string>
#include <vector>
@@ -120,12 +121,12 @@ class WriteTransactionState : public TransactionState {
void set_schema_at_decode_time(const Schema* schema) {
- lock_guard<simple_spinlock> l(&txn_state_lock_);
+ std::lock_guard<simple_spinlock> l(txn_state_lock_);
schema_at_decode_time_ = schema;
}
const Schema* schema_at_decode_time() const {
- lock_guard<simple_spinlock> l(&txn_state_lock_);
+ std::lock_guard<simple_spinlock> l(txn_state_lock_);
return schema_at_decode_time_;
}
@@ -163,7 +164,7 @@ class WriteTransactionState : public TransactionState {
}
void swap_row_ops(std::vector<RowOp*>* new_ops) {
- lock_guard<simple_spinlock> l(&txn_state_lock_);
+ std::lock_guard<simple_spinlock> l(txn_state_lock_);
row_ops_.swap(*new_ops);
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/tools/ksck.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tools/ksck.cc b/src/kudu/tools/ksck.cc
index 922506d..481141c 100644
--- a/src/kudu/tools/ksck.cc
+++ b/src/kudu/tools/ksck.cc
@@ -19,6 +19,7 @@
#include <glog/logging.h>
#include <iostream>
+#include <mutex>
#include <unordered_set>
#include "kudu/gutil/map-util.h"
@@ -209,7 +210,7 @@ class ChecksumResultReporter : public RefCountedThreadSafe<ChecksumResultReporte
const std::string& replica_uuid,
const Status& status,
uint64_t checksum) {
- lock_guard<simple_spinlock> guard(&lock_);
+ std::lock_guard<simple_spinlock> guard(lock_);
unordered_map<string, ResultPair>& replica_results =
LookupOrInsert(&checksums_, tablet_id, unordered_map<string, ResultPair>());
InsertOrDie(&replica_results, replica_uuid, ResultPair(status, checksum));
@@ -228,7 +229,7 @@ class ChecksumResultReporter : public RefCountedThreadSafe<ChecksumResultReporte
// Get reported results.
TabletResultMap checksums() const {
- lock_guard<simple_spinlock> guard(&lock_);
+ std::lock_guard<simple_spinlock> guard(lock_);
return checksums_;
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/util/cache.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/cache.cc b/src/kudu/util/cache.cc
index 2157c71..7dd8e8e 100644
--- a/src/kudu/util/cache.cc
+++ b/src/kudu/util/cache.cc
@@ -4,6 +4,7 @@
#include <glog/logging.h>
#include <memory>
+#include <mutex>
#include <stdlib.h>
#include <string>
#include <vector>
@@ -261,7 +262,7 @@ void LRUCache::LRU_Append(LRUHandle* e) {
Cache::Handle* LRUCache::Lookup(const Slice& key, uint32_t hash, bool caching) {
LRUHandle* e;
{
- lock_guard<MutexType> l(&mutex_);
+ std::lock_guard<MutexType> l(mutex_);
e = table_.Lookup(key, hash);
if (e != nullptr) {
base::RefCountInc(&e->refs);
@@ -314,7 +315,7 @@ Cache::Handle* LRUCache::Insert(LRUHandle* e, Cache::EvictionCallback *eviction_
LRUHandle* to_remove_head = nullptr;
{
- lock_guard<MutexType> l(&mutex_);
+ std::lock_guard<MutexType> l(mutex_);
LRU_Append(e);
@@ -353,7 +354,7 @@ void LRUCache::Erase(const Slice& key, uint32_t hash) {
LRUHandle* e;
bool last_reference = false;
{
- lock_guard<MutexType> l(&mutex_);
+ std::lock_guard<MutexType> l(mutex_);
e = table_.Remove(key, hash);
if (e != nullptr) {
LRU_Remove(e);
@@ -429,7 +430,7 @@ class ShardedLRUCache : public Cache {
return reinterpret_cast<LRUHandle*>(handle)->value();
}
virtual uint64_t NewId() OVERRIDE {
- lock_guard<MutexType> l(&id_mutex_);
+ std::lock_guard<MutexType> l(id_mutex_);
return ++(last_id_);
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/util/failure_detector.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/failure_detector.cc b/src/kudu/util/failure_detector.cc
index 426d345..c5c51a7 100644
--- a/src/kudu/util/failure_detector.cc
+++ b/src/kudu/util/failure_detector.cc
@@ -18,6 +18,7 @@
#include "kudu/util/failure_detector.h"
#include <glog/logging.h>
+#include <mutex>
#include <unordered_map>
#include "kudu/gutil/map-util.h"
@@ -45,7 +46,7 @@ TimedFailureDetector::~TimedFailureDetector() {
Status TimedFailureDetector::Track(const string& name,
const MonoTime& now,
const FailureDetectedCallback& callback) {
- lock_guard<simple_spinlock> lock(&lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
gscoped_ptr<Node> node(new Node);
node->permanent_name = name;
node->callback = callback;
@@ -60,7 +61,7 @@ Status TimedFailureDetector::Track(const string& name,
}
Status TimedFailureDetector::UnTrack(const string& name) {
- lock_guard<simple_spinlock> lock(&lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
Node* node = EraseKeyReturnValuePtr(&nodes_, name);
if (PREDICT_FALSE(node == NULL)) {
return Status::NotFound(Substitute("Node with name '$0' not found", name));
@@ -70,13 +71,13 @@ Status TimedFailureDetector::UnTrack(const string& name) {
}
bool TimedFailureDetector::IsTracking(const std::string& name) {
- lock_guard<simple_spinlock> lock(&lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
return ContainsKey(nodes_, name);
}
Status TimedFailureDetector::MessageFrom(const std::string& name, const MonoTime& now) {
VLOG(3) << "Received message from " << name << " at " << now.ToString();
- lock_guard<simple_spinlock> lock(&lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
Node* node = FindPtrOrNull(nodes_, name);
if (node == NULL) {
VLOG(1) << "Not tracking node: " << name;
@@ -100,7 +101,7 @@ void TimedFailureDetector::CheckForFailures(const MonoTime& now) {
typedef unordered_map<string, FailureDetectedCallback> CallbackMap;
CallbackMap callbacks;
{
- lock_guard<simple_spinlock> lock(&lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
for (const NodeMap::value_type& entry : nodes_) {
if (GetNodeStatusUnlocked(entry.first, now) == DEAD) {
InsertOrDie(&callbacks, entry.first, entry.second->callback);
@@ -143,7 +144,7 @@ void RandomizedFailureMonitor::Shutdown() {
}
{
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
if (shutdown_) {
return;
}
@@ -157,7 +158,7 @@ void RandomizedFailureMonitor::Shutdown() {
Status RandomizedFailureMonitor::MonitorFailureDetector(const string& name,
const scoped_refptr<FailureDetector>& fd) {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
bool inserted = InsertIfNotPresent(&fds_, name, fd);
if (PREDICT_FALSE(!inserted)) {
return Status::AlreadyPresent(Substitute("Already monitoring failure detector '$0'", name));
@@ -166,7 +167,7 @@ Status RandomizedFailureMonitor::MonitorFailureDetector(const string& name,
}
Status RandomizedFailureMonitor::UnmonitorFailureDetector(const string& name) {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
int count = fds_.erase(name);
if (PREDICT_FALSE(count == 0)) {
return Status::NotFound(Substitute("Failure detector '$0' not found", name));
@@ -187,7 +188,7 @@ void RandomizedFailureMonitor::RunThread() {
VLOG(3) << "RandomizedFailureMonitor sleeping for: " << wait_delta.ToString();
if (run_latch_.WaitFor(wait_delta)) {
// CountDownLatch reached 0.
- lock_guard<simple_spinlock> lock(&lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
// Check if we were told to shutdown.
if (shutdown_) {
// Latch fired: exit loop.
@@ -199,7 +200,7 @@ void RandomizedFailureMonitor::RunThread() {
// Take a copy of the FD map under the lock.
FDMap fds_copy;
{
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
fds_copy = fds_;
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/util/locks.h
----------------------------------------------------------------------
diff --git a/src/kudu/util/locks.h b/src/kudu/util/locks.h
index 423f533..e305602 100644
--- a/src/kudu/util/locks.h
+++ b/src/kudu/util/locks.h
@@ -231,74 +231,9 @@ class percpu_rwlock {
padded_lock *locks_;
};
-// Simpler version of std::lock_guard. Only supports the basic object
-// lifecycle and defers any error checking to the underlying mutex.
-template <typename Mutex>
-class lock_guard {
- public:
- explicit lock_guard(Mutex* m)
- : m_(DCHECK_NOTNULL(m)) {
- m_->lock();
- }
-
- ~lock_guard() {
- m_->unlock();
- }
-
- private:
- Mutex* m_;
- DISALLOW_COPY_AND_ASSIGN(lock_guard<Mutex>);
-};
-
-// Simpler version of boost::unique_lock. Tracks lock acquisition and will
-// report attempts to double lock() or unlock().
-template <typename Mutex>
-class unique_lock {
- public:
- unique_lock()
- : locked_(false),
- m_(NULL) {
- }
-
- explicit unique_lock(Mutex* m)
- : locked_(true),
- m_(m) {
- m_->lock();
- }
-
- ~unique_lock() {
- if (locked_) {
- m_->unlock();
- locked_ = false;
- }
- }
-
- void lock() {
- DCHECK(!locked_);
- m_->lock();
- locked_ = true;
- }
-
- void unlock() {
- DCHECK(locked_);
- m_->unlock();
- locked_ = false;
- }
-
- void swap(unique_lock<Mutex>* other) {
- DCHECK(other != NULL) << "The passed unique_lock is null";
- std::swap(locked_, other->locked_);
- std::swap(m_, other->m_);
- }
-
- private:
- bool locked_;
- Mutex* m_;
- DISALLOW_COPY_AND_ASSIGN(unique_lock<Mutex>);
-};
-
-// Simpler version of boost::shared_lock. Defers error checking to the
-// underlying mutex.
+// Simple implementation of the std::shared_lock API, which is not available in
+// the standard library until C++17. Defers error checking to the underlying
+// mutex.
template <typename Mutex>
class shared_lock {
public:
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/util/mem_tracker.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/mem_tracker.cc b/src/kudu/util/mem_tracker.cc
index 1a73284..1727780 100644
--- a/src/kudu/util/mem_tracker.cc
+++ b/src/kudu/util/mem_tracker.cc
@@ -23,6 +23,7 @@
#include <limits>
#include <list>
#include <memory>
+#include <mutex>
#include "kudu/gutil/map-util.h"
#include "kudu/gutil/once.h"
@@ -461,7 +462,7 @@ bool MemTracker::GcMemory(int64_t max_consumption) {
return true;
}
- lock_guard<simple_spinlock> l(&gc_lock_);
+ std::lock_guard<simple_spinlock> l(gc_lock_);
if (!consumption_func_.empty()) {
UpdateConsumption();
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/util/memory/arena.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/memory/arena.cc b/src/kudu/util/memory/arena.cc
index 5f935df..106bd75 100644
--- a/src/kudu/util/memory/arena.cc
+++ b/src/kudu/util/memory/arena.cc
@@ -20,10 +20,10 @@
#include "kudu/util/memory/arena.h"
#include <algorithm>
+#include <mutex>
#include "kudu/util/debug-util.h"
#include "kudu/util/flag_tags.h"
-#include "kudu/util/locks.h"
using std::copy;
using std::max;
@@ -65,7 +65,7 @@ ArenaBase<THREADSAFE>::ArenaBase(size_t initial_buffer_size, size_t max_buffer_s
template <bool THREADSAFE>
void *ArenaBase<THREADSAFE>::AllocateBytesFallback(const size_t size, const size_t align) {
- lock_guard<mutex_type> lock(&component_lock_);
+ std::lock_guard<mutex_type> lock(component_lock_);
// It's possible another thread raced with us and already allocated
// a new component, in which case we should try the "fast path" again
@@ -139,7 +139,7 @@ void ArenaBase<THREADSAFE>::AddComponent(ArenaBase::Component *component) {
template <bool THREADSAFE>
void ArenaBase<THREADSAFE>::Reset() {
- lock_guard<mutex_type> lock(&component_lock_);
+ std::lock_guard<mutex_type> lock(component_lock_);
if (PREDICT_FALSE(arena_.size() > 1)) {
unique_ptr<Component> last = std::move(arena_.back());
@@ -163,7 +163,7 @@ void ArenaBase<THREADSAFE>::Reset() {
template <bool THREADSAFE>
size_t ArenaBase<THREADSAFE>::memory_footprint() const {
- lock_guard<mutex_type> lock(&component_lock_);
+ std::lock_guard<mutex_type> lock(component_lock_);
return arena_footprint_;
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/util/memory/arena.h
----------------------------------------------------------------------
diff --git a/src/kudu/util/memory/arena.h b/src/kudu/util/memory/arena.h
index 4abd1d5..d192a56 100644
--- a/src/kudu/util/memory/arena.h
+++ b/src/kudu/util/memory/arena.h
@@ -26,18 +26,20 @@
#include <boost/signals2/dummy_mutex.hpp>
#include <glog/logging.h>
#include <memory>
+#include <mutex>
#include <new>
#include <stddef.h>
#include <string.h>
#include <vector>
#include "kudu/gutil/dynamic_annotations.h"
+#include "kudu/gutil/gscoped_ptr.h"
#include "kudu/gutil/logging-inl.h"
#include "kudu/gutil/macros.h"
-#include "kudu/gutil/gscoped_ptr.h"
#include "kudu/util/alignment.h"
#include "kudu/util/locks.h"
#include "kudu/util/memory/memory.h"
+#include "kudu/util/mutex.h"
#include "kudu/util/slice.h"
using std::allocator;
@@ -426,7 +428,7 @@ inline uint8_t *ArenaBase<false>::Component::AllocateBytesAligned(
template <bool THREADSAFE>
inline void ArenaBase<THREADSAFE>::Component::AsanUnpoison(const void* addr, size_t size) {
#ifdef ADDRESS_SANITIZER
- lock_guard<spinlock_type> l(&asan_lock_);
+ std::lock_guard<spinlock_type> l(asan_lock_);
ASAN_UNPOISON_MEMORY_REGION(addr, size);
#endif
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/util/metrics.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/metrics.cc b/src/kudu/util/metrics.cc
index 2935cbc..31e2d50 100644
--- a/src/kudu/util/metrics.cc
+++ b/src/kudu/util/metrics.cc
@@ -170,7 +170,7 @@ void MetricEntity::CheckInstantiation(const MetricPrototype* proto) const {
}
scoped_refptr<Metric> MetricEntity::FindOrNull(const MetricPrototype& prototype) const {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
return FindPtrOrNull(metric_map_, &prototype);
}
@@ -203,7 +203,7 @@ Status MetricEntity::WriteAsJson(JsonWriter* writer,
AttributeMap attrs;
{
// Snapshot the metrics in this registry (not guaranteed to be a consistent snapshot)
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
attrs = attributes_;
for (const MetricMap::value_type& val : metric_map_) {
const MetricPrototype* prototype = val.first;
@@ -254,7 +254,7 @@ Status MetricEntity::WriteAsJson(JsonWriter* writer,
void MetricEntity::RetireOldMetrics() {
MonoTime now(MonoTime::Now(MonoTime::FINE));
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
for (auto it = metric_map_.begin(); it != metric_map_.end();) {
const scoped_refptr<Metric>& metric = it->second;
@@ -298,17 +298,17 @@ void MetricEntity::RetireOldMetrics() {
}
void MetricEntity::NeverRetire(const scoped_refptr<Metric>& metric) {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
never_retire_metrics_.push_back(metric);
}
void MetricEntity::SetAttributes(const AttributeMap& attrs) {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
attributes_ = attrs;
}
void MetricEntity::SetAttribute(const string& key, const string& val) {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
attributes_[key] = val;
}
@@ -327,7 +327,7 @@ Status MetricRegistry::WriteAsJson(JsonWriter* writer,
const MetricJsonOptions& opts) const {
EntityMap entities;
{
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
entities = entities_;
}
@@ -349,7 +349,7 @@ Status MetricRegistry::WriteAsJson(JsonWriter* writer,
}
void MetricRegistry::RetireOldMetrics() {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
for (auto it = entities_.begin(); it != entities_.end();) {
it->second->RetireOldMetrics();
@@ -373,17 +373,17 @@ MetricPrototypeRegistry* MetricPrototypeRegistry::get() {
}
void MetricPrototypeRegistry::AddMetric(const MetricPrototype* prototype) {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
metrics_.push_back(prototype);
}
void MetricPrototypeRegistry::AddEntity(const MetricEntityPrototype* prototype) {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
entities_.push_back(prototype);
}
void MetricPrototypeRegistry::WriteAsJson(JsonWriter* writer) const {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
MetricJsonOptions opts;
opts.include_schema_info = true;
writer->StartObject();
@@ -466,7 +466,7 @@ scoped_refptr<MetricEntity> MetricRegistry::FindOrCreateEntity(
const MetricEntityPrototype* prototype,
const std::string& id,
const MetricEntity::AttributeMap& initial_attributes) {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
scoped_refptr<MetricEntity> e = FindPtrOrNull(entities_, id);
if (!e) {
e = new MetricEntity(prototype, id, initial_attributes);
@@ -513,12 +513,12 @@ StringGauge::StringGauge(const GaugePrototype<string>* proto,
: Gauge(proto), value_(std::move(initial_value)) {}
std::string StringGauge::value() const {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
return value_;
}
void StringGauge::set_value(const std::string& value) {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
value_ = value;
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/util/metrics.h
----------------------------------------------------------------------
diff --git a/src/kudu/util/metrics.h b/src/kudu/util/metrics.h
index b55cd08..4952410 100644
--- a/src/kudu/util/metrics.h
+++ b/src/kudu/util/metrics.h
@@ -224,6 +224,7 @@
/////////////////////////////////////////////////////
#include <algorithm>
+#include <mutex>
#include <string>
#include <unordered_map>
#include <vector>
@@ -486,7 +487,7 @@ class MetricEntity : public RefCountedThreadSafe<MetricEntity> {
void SetAttribute(const std::string& key, const std::string& val);
int num_metrics() const {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
return metric_map_.size();
}
@@ -580,7 +581,7 @@ class MetricRegistry {
// Return the number of entities in this registry.
int num_entities() const {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
return entities_.size();
}
@@ -850,7 +851,7 @@ template <typename T>
class FunctionGauge : public Gauge {
public:
T value() const {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
return function_.Run();
}
@@ -862,7 +863,7 @@ class FunctionGauge : public Gauge {
// This should be used during destruction. If you want a settable
// Gauge, use a normal Gauge instead of a FunctionGauge.
void DetachToConstant(T v) {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
function_ = Bind(&FunctionGauge::Return, v);
}
@@ -1019,7 +1020,7 @@ class ScopedLatencyMetric {
inline scoped_refptr<Counter> MetricEntity::FindOrCreateCounter(
const CounterPrototype* proto) {
CheckInstantiation(proto);
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
scoped_refptr<Counter> m = down_cast<Counter*>(FindPtrOrNull(metric_map_, proto).get());
if (!m) {
m = new Counter(proto);
@@ -1031,7 +1032,7 @@ inline scoped_refptr<Counter> MetricEntity::FindOrCreateCounter(
inline scoped_refptr<Histogram> MetricEntity::FindOrCreateHistogram(
const HistogramPrototype* proto) {
CheckInstantiation(proto);
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
scoped_refptr<Histogram> m = down_cast<Histogram*>(FindPtrOrNull(metric_map_, proto).get());
if (!m) {
m = new Histogram(proto);
@@ -1045,7 +1046,7 @@ inline scoped_refptr<AtomicGauge<T> > MetricEntity::FindOrCreateGauge(
const GaugePrototype<T>* proto,
const T& initial_value) {
CheckInstantiation(proto);
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
scoped_refptr<AtomicGauge<T> > m = down_cast<AtomicGauge<T>*>(
FindPtrOrNull(metric_map_, proto).get());
if (!m) {
@@ -1060,7 +1061,7 @@ inline scoped_refptr<FunctionGauge<T> > MetricEntity::FindOrCreateFunctionGauge(
const GaugePrototype<T>* proto,
const Callback<T()>& function) {
CheckInstantiation(proto);
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
scoped_refptr<FunctionGauge<T> > m = down_cast<FunctionGauge<T>*>(
FindPtrOrNull(metric_map_, proto).get());
if (!m) {
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/util/nvm_cache.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/nvm_cache.cc b/src/kudu/util/nvm_cache.cc
index c8a3465..678aa87 100644
--- a/src/kudu/util/nvm_cache.cc
+++ b/src/kudu/util/nvm_cache.cc
@@ -25,6 +25,7 @@
#include <iostream>
#include <libvmem.h>
#include <memory>
+#include <mutex>
#include <stdlib.h>
#include <string>
#include <vector>
@@ -299,7 +300,7 @@ void *NvmLRUCache::AllocateAndRetry(size_t size) {
tmp = VmemMalloc(size);
if (tmp == NULL) {
- unique_lock<MutexType> l(&mutex_);
+ std::unique_lock<MutexType> l(mutex_);
int retries_remaining = FLAGS_nvm_cache_allocation_retry_count;
while (tmp == NULL && retries_remaining-- > 0 && lru_.next != &lru_) {
@@ -336,7 +337,7 @@ void NvmLRUCache::NvmLRU_Append(LRUHandle* e) {
Cache::Handle* NvmLRUCache::Lookup(const Slice& key, uint32_t hash, bool caching) {
LRUHandle* e;
{
- lock_guard<MutexType> l(&mutex_);
+ std::lock_guard<MutexType> l(mutex_);
e = table_.Lookup(key, hash);
if (e != NULL) {
// If an entry exists, remove the old entry from the cache
@@ -408,7 +409,7 @@ Cache::Handle* NvmLRUCache::Insert(LRUHandle* e,
}
{
- lock_guard<MutexType> l(&mutex_);
+ std::lock_guard<MutexType> l(mutex_);
NvmLRU_Append(e);
@@ -437,7 +438,7 @@ void NvmLRUCache::Erase(const Slice& key, uint32_t hash) {
LRUHandle* e;
bool last_reference = false;
{
- lock_guard<MutexType> l(&mutex_);
+ std::lock_guard<MutexType> l(mutex_);
e = table_.Remove(key, hash);
if (e != NULL) {
NvmLRU_Remove(e);
@@ -516,7 +517,7 @@ class ShardedLRUCache : public Cache {
}
virtual uint64_t NewId() OVERRIDE {
- lock_guard<MutexType> l(&id_mutex_);
+ std::lock_guard<MutexType> l(id_mutex_);
return ++(last_id_);
}
virtual void SetMetrics(const scoped_refptr<MetricEntity>& entity) OVERRIDE {
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/util/path_util.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/path_util.cc b/src/kudu/util/path_util.cc
index 872886b..7131431 100644
--- a/src/kudu/util/path_util.cc
+++ b/src/kudu/util/path_util.cc
@@ -26,7 +26,7 @@
#include "kudu/gutil/gscoped_ptr.h"
#if defined(__APPLE__)
-#include "kudu/util/locks.h"
+#include <mutex>
#endif // defined(__APPLE__)
using std::string;
@@ -49,8 +49,8 @@ std::string JoinPathSegments(const std::string &a,
string DirName(const string& path) {
gscoped_ptr<char[], FreeDeleter> path_copy(strdup(path.c_str()));
#if defined(__APPLE__)
- static Mutex lock;
- lock_guard<Mutex> l(&lock);
+ static std::mutex lock;
+ std::lock_guard<std::mutex> l(lock);
#endif // defined(__APPLE__)
return ::dirname(path_copy.get());
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/util/random.h
----------------------------------------------------------------------
diff --git a/src/kudu/util/random.h b/src/kudu/util/random.h
index c466229..8f9ab22 100644
--- a/src/kudu/util/random.h
+++ b/src/kudu/util/random.h
@@ -6,6 +6,7 @@
#include <cmath>
#include <cstdint>
+#include <mutex>
#include <random>
#include <vector>
@@ -158,59 +159,59 @@ class ThreadSafeRandom {
}
void Reset(uint32_t s) {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
random_.Reset(s);
}
uint32_t Next() {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
return random_.Next();
}
uint32_t Next32() {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
return random_.Next32();
}
uint64_t Next64() {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
return random_.Next64();
}
uint32_t Uniform(uint32_t n) {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
return random_.Uniform(n);
}
uint32_t Uniform32(uint32_t n) {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
return random_.Uniform32(n);
}
uint64_t Uniform64(uint64_t n) {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
return random_.Uniform64(n);
}
bool OneIn(int n) {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
return random_.OneIn(n);
}
uint32_t Skewed(int max_log) {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
return random_.Skewed(max_log);
}
double Normal(double mean, double std_dev) {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
return random_.Normal(mean, std_dev);
}
template<class Collection, class Set, class T>
void ReservoirSample(const Collection& c, int k, const Set& avoid,
std::vector<T>* result) {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
random_.ReservoirSample(c, k, avoid, result);
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/util/resettable_heartbeater.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/resettable_heartbeater.cc b/src/kudu/util/resettable_heartbeater.cc
index a1c68b9..91c4587 100644
--- a/src/kudu/util/resettable_heartbeater.cc
+++ b/src/kudu/util/resettable_heartbeater.cc
@@ -15,10 +15,11 @@
// specific language governing permissions and limitations
// under the License.
-#include <glog/logging.h>
-
#include "kudu/util/resettable_heartbeater.h"
+#include <glog/logging.h>
+#include <mutex>
+
#include "kudu/gutil/ref_counted.h"
#include "kudu/gutil/strings/substitute.h"
#include "kudu/util/countdown_latch.h"
@@ -115,7 +116,7 @@ void ResettableHeartbeaterThread::RunThread() {
if (run_latch_.WaitFor(wait_period)) {
// CountDownLatch reached 0 -- this means there was a manual reset.
prev_reset_was_manual = true;
- lock_guard<simple_spinlock> lock(&lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
// check if we were told to shutdown
if (shutdown_) {
// Latch fired -- exit loop
@@ -163,7 +164,7 @@ Status ResettableHeartbeaterThread::Stop() {
}
{
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
if (shutdown_) {
return Status::OK();
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/util/test_graph.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/test_graph.cc b/src/kudu/util/test_graph.cc
index c3dc9e1..052ad9c 100644
--- a/src/kudu/util/test_graph.cc
+++ b/src/kudu/util/test_graph.cc
@@ -15,14 +15,16 @@
// specific language governing permissions and limitations
// under the License.
+#include "kudu/util/test_graph.h"
+
#include <glog/logging.h>
+#include <mutex>
#include "kudu/gutil/ref_counted.h"
#include "kudu/gutil/stringprintf.h"
#include "kudu/gutil/walltime.h"
#include "kudu/util/locks.h"
#include "kudu/util/status.h"
-#include "kudu/util/test_graph.h"
#include "kudu/util/thread.h"
using std::shared_ptr;
@@ -31,17 +33,17 @@ using std::string;
namespace kudu {
void TimeSeries::AddValue(double val) {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
val_ += val;
}
void TimeSeries::SetValue(double val) {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
val_ = val;
}
double TimeSeries::value() const {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
return val_;
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/util/trace.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/trace.cc b/src/kudu/util/trace.cc
index 9b556b5..f5793cb 100644
--- a/src/kudu/util/trace.cc
+++ b/src/kudu/util/trace.cc
@@ -21,6 +21,7 @@
#include <ios>
#include <iostream>
#include <map>
+#include <mutex>
#include <string>
#include <strstream>
#include <utility>
@@ -106,7 +107,7 @@ TraceEntry* Trace::NewEntry(int msg_len, const char* file_path, int line_number)
}
void Trace::AddEntry(TraceEntry* entry) {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
entry->next = nullptr;
if (entries_tail_ != nullptr) {
@@ -126,7 +127,7 @@ void Trace::Dump(std::ostream* out, int flags) const {
vector<TraceEntry*> entries;
vector<pair<StringPiece, scoped_refptr<Trace>>> child_traces;
{
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
for (TraceEntry* cur = entries_head_;
cur != nullptr;
cur = cur->next) {
@@ -241,13 +242,13 @@ void Trace::DumpCurrentTrace() {
void Trace::AddChildTrace(StringPiece label, Trace* child_trace) {
CHECK(arena_->RelocateStringPiece(label, &label));
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
scoped_refptr<Trace> ptr(child_trace);
child_traces_.emplace_back(label, ptr);
}
std::vector<std::pair<StringPiece, scoped_refptr<Trace>>> Trace::ChildTraces() const {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
return child_traces_;
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/util/trace_metrics.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/trace_metrics.cc b/src/kudu/util/trace_metrics.cc
index 20569fc..32ff1c4 100644
--- a/src/kudu/util/trace_metrics.cc
+++ b/src/kudu/util/trace_metrics.cc
@@ -21,6 +21,7 @@
#include <ctype.h>
#include <glog/stl_logging.h>
#include <map>
+#include <mutex>
#include <string>
#include "kudu/util/debug/leakcheck_disabler.h"
@@ -42,7 +43,7 @@ const char* TraceMetrics::InternName(const string& name) {
<< "not printable: " << name;
debug::ScopedLeakCheckDisabler no_leakcheck;
- lock_guard<simple_spinlock> l(&g_intern_map_lock);
+ std::lock_guard<simple_spinlock> l(g_intern_map_lock);
if (g_intern_map == nullptr) {
g_intern_map = new InternMap();
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/util/trace_metrics.h
----------------------------------------------------------------------
diff --git a/src/kudu/util/trace_metrics.h b/src/kudu/util/trace_metrics.h
index 4ef6d63..fbe1774 100644
--- a/src/kudu/util/trace_metrics.h
+++ b/src/kudu/util/trace_metrics.h
@@ -21,6 +21,7 @@
#include "kudu/util/locks.h"
#include <map>
+#include <mutex>
#include <string>
namespace kudu {
@@ -73,12 +74,12 @@ class TraceMetrics {
};
inline void TraceMetrics::Increment(const char* name, int64_t amount) {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
counters_[name] += amount;
}
inline std::map<const char*, int64_t> TraceMetrics::Get() const {
- unique_lock<simple_spinlock> l(&lock_);
+ std::unique_lock<simple_spinlock> l(lock_);
auto m = counters_;
l.unlock();
[3/5] incubator-kudu git commit: Replace boost::{lock, unique_lock,
mutex} with std lib equivalents
Posted by da...@apache.org.
Replace boost::{lock, unique_lock, mutex} with std lib equivalents
Change-Id: I0c27f72c726258793991006a728673af537414bb
Reviewed-on: http://gerrit.cloudera.org:8080/3262
Reviewed-by: Mike Percy <mp...@apache.org>
Tested-by: Kudu Jenkins
Project: http://git-wip-us.apache.org/repos/asf/incubator-kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-kudu/commit/cfa9a99f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-kudu/tree/cfa9a99f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-kudu/diff/cfa9a99f
Branch: refs/heads/master
Commit: cfa9a99f92d486c9d9afda82ce06f4f7f7efee4d
Parents: 0e9fd8c
Author: Dan Burkert <da...@cloudera.com>
Authored: Thu May 21 12:31:38 2015 -0700
Committer: Dan Burkert <da...@cloudera.com>
Committed: Thu Jun 2 00:51:53 2016 +0000
----------------------------------------------------------------------
src/kudu/benchmarks/tpch/rpc_line_item_dao.cc | 2 +-
src/kudu/cfile/bloomfile.cc | 2 -
src/kudu/consensus/consensus-test-util.h | 71 ++++++++--------
src/kudu/consensus/consensus_peers.cc | 9 ++-
src/kudu/consensus/consensus_queue.cc | 42 +++++-----
src/kudu/consensus/local_consensus.cc | 14 ++--
src/kudu/consensus/local_consensus.h | 1 -
src/kudu/consensus/log.cc | 22 ++---
src/kudu/consensus/log_anchor_registry.cc | 22 ++---
src/kudu/consensus/log_reader.cc | 32 ++++----
src/kudu/consensus/mt-log-test.cc | 6 +-
src/kudu/consensus/peer_manager.cc | 8 +-
src/kudu/consensus/raft_consensus.cc | 7 +-
src/kudu/consensus/raft_consensus.h | 5 +-
src/kudu/experiments/rwlock-perf.cc | 6 +-
src/kudu/master/catalog_manager.cc | 85 ++++++++++----------
src/kudu/master/catalog_manager.h | 1 -
src/kudu/master/ts_descriptor.cc | 41 +++++-----
src/kudu/master/ts_manager.cc | 6 +-
src/kudu/server/hybrid_clock.cc | 24 +++---
src/kudu/server/webserver.cc | 20 ++---
src/kudu/server/webserver.h | 3 +-
src/kudu/tablet/compaction.h | 11 ++-
src/kudu/tablet/diskrowset.cc | 7 +-
src/kudu/tablet/diskrowset.h | 6 +-
src/kudu/tablet/lock_manager-test.cc | 9 +--
src/kudu/tablet/lock_manager.cc | 17 ++--
src/kudu/tablet/memrowset.h | 7 +-
src/kudu/tablet/mock-rowsets.h | 3 +-
src/kudu/tablet/mvcc-test.cc | 6 +-
src/kudu/tablet/mvcc.cc | 38 ++++-----
src/kudu/tablet/rowset.h | 8 +-
src/kudu/tablet/tablet.cc | 68 ++++++++--------
src/kudu/tablet/tablet.h | 6 +-
src/kudu/tablet/tablet_bootstrap.cc | 3 +-
src/kudu/tablet/tablet_metadata.cc | 38 ++++-----
src/kudu/tablet/tablet_peer.cc | 24 +++---
src/kudu/tablet/tablet_peer.h | 17 ++--
src/kudu/tablet/tablet_peer_mm_ops.cc | 15 ++--
.../tablet/transactions/transaction_driver.cc | 30 +++----
.../tablet/transactions/write_transaction.cc | 1 -
src/kudu/tserver/scanners.cc | 13 +--
src/kudu/tserver/scanners.h | 9 ++-
src/kudu/tserver/ts_tablet_manager.cc | 28 +++----
src/kudu/tserver/ts_tablet_manager.h | 2 +-
src/kudu/twitter-demo/insert_consumer.cc | 6 +-
src/kudu/twitter-demo/twitter_streamer.cc | 4 +-
src/kudu/twitter-demo/twitter_streamer.h | 4 +-
src/kudu/util/boost_mutex_utils.h | 8 +-
src/kudu/util/locks.h | 2 +-
src/kudu/util/mt-threadlocal-test.cc | 14 ++--
src/kudu/util/oid_generator.cc | 3 +-
src/kudu/util/rw_semaphore-test.cc | 7 +-
src/kudu/util/rwc_lock-test.cc | 8 +-
src/kudu/util/throttler.cc | 4 +-
src/kudu/util/throttler.h | 2 -
56 files changed, 431 insertions(+), 426 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/benchmarks/tpch/rpc_line_item_dao.cc
----------------------------------------------------------------------
diff --git a/src/kudu/benchmarks/tpch/rpc_line_item_dao.cc b/src/kudu/benchmarks/tpch/rpc_line_item_dao.cc
index 71818aa..f76af5b 100644
--- a/src/kudu/benchmarks/tpch/rpc_line_item_dao.cc
+++ b/src/kudu/benchmarks/tpch/rpc_line_item_dao.cc
@@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.
-#include <boost/thread/locks.hpp>
+#include <boost/function.hpp>
#include <glog/logging.h>
#include <vector>
#include <utility>
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/cfile/bloomfile.cc
----------------------------------------------------------------------
diff --git a/src/kudu/cfile/bloomfile.cc b/src/kudu/cfile/bloomfile.cc
index 9390de3..5e47f9d 100644
--- a/src/kudu/cfile/bloomfile.cc
+++ b/src/kudu/cfile/bloomfile.cc
@@ -15,8 +15,6 @@
// specific language governing permissions and limitations
// under the License.
-#include <boost/thread/locks.hpp>
-#include <boost/thread/mutex.hpp>
#include <mutex>
#include <sched.h>
#include <string>
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/consensus/consensus-test-util.h
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/consensus-test-util.h b/src/kudu/consensus/consensus-test-util.h
index 4a45634..4d50bd9 100644
--- a/src/kudu/consensus/consensus-test-util.h
+++ b/src/kudu/consensus/consensus-test-util.h
@@ -15,10 +15,11 @@
// specific language governing permissions and limitations
// under the License.
-#include <boost/thread/locks.hpp>
+#include <boost/bind.hpp>
#include <gmock/gmock.h>
#include <map>
#include <memory>
+#include <mutex>
#include <string>
#include <unordered_map>
#include <utility>
@@ -131,7 +132,7 @@ class TestPeerProxy : public PeerProxy {
// Register the RPC callback in order to call later.
// We currently only support one request of each method being in flight at a time.
virtual void RegisterCallback(Method method, const rpc::ResponseCallback& callback) {
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
InsertOrDie(&callbacks_, method, callback);
}
@@ -139,7 +140,7 @@ class TestPeerProxy : public PeerProxy {
virtual void Respond(Method method) {
rpc::ResponseCallback callback;
{
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
callback = FindOrDie(callbacks_, method);
CHECK_EQ(1, callbacks_.erase(method));
// Drop the lock before submitting to the pool, since the callback itself may
@@ -299,7 +300,7 @@ class NoOpTestPeerProxy : public TestPeerProxy {
response->Clear();
{
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
if (OpIdLessThan(last_received_, request->preceding_id())) {
ConsensusErrorPB* error = response->mutable_status()->mutable_error();
error->set_code(ConsensusErrorPB::PRECEDING_ENTRY_DIDNT_MATCH);
@@ -325,7 +326,7 @@ class NoOpTestPeerProxy : public TestPeerProxy {
rpc::RpcController* controller,
const rpc::ResponseCallback& callback) OVERRIDE {
{
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
response->set_responder_uuid(peer_pb_.permanent_uuid());
response->set_responder_term(request->candidate_term());
response->set_vote_granted(true);
@@ -334,7 +335,7 @@ class NoOpTestPeerProxy : public TestPeerProxy {
}
const OpId& last_received() {
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
return last_received_;
}
@@ -367,7 +368,7 @@ class TestPeerMapManager {
explicit TestPeerMapManager(const RaftConfigPB& config) : config_(config) {}
void AddPeer(const std::string& peer_uuid, const scoped_refptr<RaftConsensus>& peer) {
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
InsertOrDie(&peers_, peer_uuid, peer);
}
@@ -378,7 +379,7 @@ class TestPeerMapManager {
Status GetPeerByUuid(const std::string& peer_uuid,
scoped_refptr<RaftConsensus>* peer_out) const {
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
if (!FindCopy(peers_, peer_uuid, peer_out)) {
return Status::NotFound("Other consensus instance was destroyed");
}
@@ -386,12 +387,12 @@ class TestPeerMapManager {
}
void RemovePeer(const std::string& peer_uuid) {
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
peers_.erase(peer_uuid);
}
TestPeerMap GetPeerMapCopy() const {
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
return peers_;
}
@@ -402,7 +403,7 @@ class TestPeerMapManager {
// destroys the test proxies which in turn reach into this class.
TestPeerMap copy = peers_;
{
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
peers_.clear();
}
@@ -460,7 +461,7 @@ class LocalTestPeerProxy : public TestPeerProxy {
bool miss_comm_copy;
{
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
miss_comm_copy = miss_comm_;
miss_comm_ = false;
}
@@ -535,7 +536,7 @@ class LocalTestPeerProxy : public TestPeerProxy {
void InjectCommFaultLeaderSide() {
VLOG(2) << this << ": injecting fault next time";
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
miss_comm_ = true;
}
@@ -706,121 +707,121 @@ class CounterHooks : public Consensus::ConsensusFaultHooks {
virtual Status PreStart() OVERRIDE {
if (current_hook_.get()) RETURN_NOT_OK(current_hook_->PreStart());
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
pre_start_calls_++;
return Status::OK();
}
virtual Status PostStart() OVERRIDE {
if (current_hook_.get()) RETURN_NOT_OK(current_hook_->PostStart());
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
post_start_calls_++;
return Status::OK();
}
virtual Status PreConfigChange() OVERRIDE {
if (current_hook_.get()) RETURN_NOT_OK(current_hook_->PreConfigChange());
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
pre_config_change_calls_++;
return Status::OK();
}
virtual Status PostConfigChange() OVERRIDE {
if (current_hook_.get()) RETURN_NOT_OK(current_hook_->PostConfigChange());
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
post_config_change_calls_++;
return Status::OK();
}
virtual Status PreReplicate() OVERRIDE {
if (current_hook_.get()) RETURN_NOT_OK(current_hook_->PreReplicate());
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
pre_replicate_calls_++;
return Status::OK();
}
virtual Status PostReplicate() OVERRIDE {
if (current_hook_.get()) RETURN_NOT_OK(current_hook_->PostReplicate());
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
post_replicate_calls_++;
return Status::OK();
}
virtual Status PreUpdate() OVERRIDE {
if (current_hook_.get()) RETURN_NOT_OK(current_hook_->PreUpdate());
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
pre_update_calls_++;
return Status::OK();
}
virtual Status PostUpdate() OVERRIDE {
if (current_hook_.get()) RETURN_NOT_OK(current_hook_->PostUpdate());
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
post_update_calls_++;
return Status::OK();
}
virtual Status PreShutdown() OVERRIDE {
if (current_hook_.get()) RETURN_NOT_OK(current_hook_->PreShutdown());
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
pre_shutdown_calls_++;
return Status::OK();
}
virtual Status PostShutdown() OVERRIDE {
if (current_hook_.get()) RETURN_NOT_OK(current_hook_->PostShutdown());
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
post_shutdown_calls_++;
return Status::OK();
}
int num_pre_start_calls() {
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
return pre_start_calls_;
}
int num_post_start_calls() {
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
return post_start_calls_;
}
int num_pre_config_change_calls() {
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
return pre_config_change_calls_;
}
int num_post_config_change_calls() {
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
return post_config_change_calls_;
}
int num_pre_replicate_calls() {
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
return pre_replicate_calls_;
}
int num_post_replicate_calls() {
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
return post_replicate_calls_;
}
int num_pre_update_calls() {
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
return pre_update_calls_;
}
int num_post_update_calls() {
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
return post_update_calls_;
}
int num_pre_shutdown_calls() {
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
return pre_shutdown_calls_;
}
int num_post_shutdown_calls() {
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
return post_shutdown_calls_;
}
@@ -844,14 +845,14 @@ class CounterHooks : public Consensus::ConsensusFaultHooks {
class TestRaftConsensusQueueIface : public PeerMessageQueueObserver {
public:
bool IsMajorityReplicated(int64_t index) {
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
return index <= majority_replicated_index_;
}
protected:
virtual void UpdateMajorityReplicated(const OpId& majority_replicated,
OpId* committed_index) OVERRIDE {
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
majority_replicated_index_ = majority_replicated.index();
committed_index->CopyFrom(majority_replicated);
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/consensus/consensus_peers.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/consensus_peers.cc b/src/kudu/consensus/consensus_peers.cc
index 76f82da..5220e53 100644
--- a/src/kudu/consensus/consensus_peers.cc
+++ b/src/kudu/consensus/consensus_peers.cc
@@ -21,6 +21,7 @@
#include <boost/bind.hpp>
#include <gflags/gflags.h>
#include <glog/logging.h>
+#include <mutex>
#include <string>
#include <utility>
#include <vector>
@@ -115,7 +116,7 @@ void Peer::SetTermForTest(int term) {
}
Status Peer::Init() {
- boost::lock_guard<simple_spinlock> lock(peer_lock_);
+ std::lock_guard<simple_spinlock> lock(peer_lock_);
queue_->TrackPeer(peer_pb_.permanent_uuid());
RETURN_NOT_OK(heartbeater_.Start());
state_ = kPeerStarted;
@@ -129,7 +130,7 @@ Status Peer::SignalRequest(bool even_if_queue_empty) {
return Status::OK();
}
{
- boost::lock_guard<simple_spinlock> l(peer_lock_);
+ std::lock_guard<simple_spinlock> l(peer_lock_);
if (PREDICT_FALSE(state_ == kPeerClosed)) {
sem_.Release();
@@ -343,7 +344,7 @@ void Peer::Close() {
// If the peer is already closed return.
{
- boost::lock_guard<simple_spinlock> lock(peer_lock_);
+ std::lock_guard<simple_spinlock> lock(peer_lock_);
if (state_ == kPeerClosed) return;
DCHECK(state_ == kPeerRunning || state_ == kPeerStarted) << "Unexpected state: " << state_;
state_ = kPeerClosed;
@@ -353,7 +354,7 @@ void Peer::Close() {
// Acquire the semaphore to wait for any concurrent request to finish.
// They will see the state_ == kPeerClosed and not start any new requests,
// but we can't currently cancel the already-sent ones. (see KUDU-699)
- boost::lock_guard<Semaphore> l(sem_);
+ std::lock_guard<Semaphore> l(sem_);
queue_->UntrackPeer(peer_pb_.permanent_uuid());
// We don't own the ops (the queue does).
request_.mutable_ops()->ExtractSubrange(0, request_.ops_size(), nullptr);
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/consensus/consensus_queue.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/consensus_queue.cc b/src/kudu/consensus/consensus_queue.cc
index 040a5c2..0a8f478 100644
--- a/src/kudu/consensus/consensus_queue.cc
+++ b/src/kudu/consensus/consensus_queue.cc
@@ -17,9 +17,9 @@
#include "kudu/consensus/consensus_queue.h"
#include <algorithm>
-#include <boost/thread/locks.hpp>
#include <gflags/gflags.h>
#include <iostream>
+#include <mutex>
#include <string>
#include <utility>
@@ -119,7 +119,7 @@ PeerMessageQueue::PeerMessageQueue(const scoped_refptr<MetricEntity>& metric_ent
}
void PeerMessageQueue::Init(const OpId& last_locally_replicated) {
- boost::lock_guard<simple_spinlock> lock(queue_lock_);
+ std::lock_guard<simple_spinlock> lock(queue_lock_);
CHECK_EQ(queue_state_.state, kQueueConstructed);
log_cache_.Init(last_locally_replicated);
queue_state_.last_appended = last_locally_replicated;
@@ -130,7 +130,7 @@ void PeerMessageQueue::Init(const OpId& last_locally_replicated) {
void PeerMessageQueue::SetLeaderMode(const OpId& committed_index,
int64_t current_term,
const RaftConfigPB& active_config) {
- boost::lock_guard<simple_spinlock> lock(queue_lock_);
+ std::lock_guard<simple_spinlock> lock(queue_lock_);
CHECK(committed_index.IsInitialized());
queue_state_.current_term = current_term;
queue_state_.committed_index = committed_index;
@@ -155,7 +155,7 @@ void PeerMessageQueue::SetLeaderMode(const OpId& committed_index,
}
void PeerMessageQueue::SetNonLeaderMode() {
- boost::lock_guard<simple_spinlock> lock(queue_lock_);
+ std::lock_guard<simple_spinlock> lock(queue_lock_);
queue_state_.active_config.reset();
queue_state_.mode = NON_LEADER;
queue_state_.majority_size_ = -1;
@@ -164,7 +164,7 @@ void PeerMessageQueue::SetNonLeaderMode() {
}
void PeerMessageQueue::TrackPeer(const string& uuid) {
- boost::lock_guard<simple_spinlock> lock(queue_lock_);
+ std::lock_guard<simple_spinlock> lock(queue_lock_);
TrackPeerUnlocked(uuid);
}
@@ -192,7 +192,7 @@ void PeerMessageQueue::TrackPeerUnlocked(const string& uuid) {
}
void PeerMessageQueue::UntrackPeer(const string& uuid) {
- boost::lock_guard<simple_spinlock> lock(queue_lock_);
+ std::lock_guard<simple_spinlock> lock(queue_lock_);
TrackedPeer* peer = EraseKeyReturnValuePtr(&peers_map_, uuid);
if (peer != nullptr) {
delete peer;
@@ -229,7 +229,7 @@ void PeerMessageQueue::LocalPeerAppendFinished(const OpId& id,
*fake_response.mutable_status()->mutable_last_received() = id;
*fake_response.mutable_status()->mutable_last_received_current_leader() = id;
{
- boost::unique_lock<simple_spinlock> lock(queue_lock_);
+ std::unique_lock<simple_spinlock> lock(queue_lock_);
fake_response.mutable_status()->set_last_committed_idx(queue_state_.committed_index.index());
}
bool junk;
@@ -246,7 +246,7 @@ Status PeerMessageQueue::AppendOperations(const vector<ReplicateRefPtr>& msgs,
const StatusCallback& log_append_callback) {
DFAKE_SCOPED_LOCK(append_fake_lock_);
- boost::unique_lock<simple_spinlock> lock(queue_lock_);
+ std::unique_lock<simple_spinlock> lock(queue_lock_);
OpId last_id = msgs.back()->get()->id();
@@ -652,17 +652,17 @@ PeerMessageQueue::TrackedPeer PeerMessageQueue::GetTrackedPeerForTests(string uu
}
OpId PeerMessageQueue::GetAllReplicatedIndexForTests() const {
- boost::lock_guard<simple_spinlock> lock(queue_lock_);
+ std::lock_guard<simple_spinlock> lock(queue_lock_);
return queue_state_.all_replicated_opid;
}
OpId PeerMessageQueue::GetCommittedIndexForTests() const {
- boost::lock_guard<simple_spinlock> lock(queue_lock_);
+ std::lock_guard<simple_spinlock> lock(queue_lock_);
return queue_state_.committed_index;
}
OpId PeerMessageQueue::GetMajorityReplicatedOpIdForTests() const {
- boost::lock_guard<simple_spinlock> lock(queue_lock_);
+ std::lock_guard<simple_spinlock> lock(queue_lock_);
return queue_state_.majority_replicated_opid;
}
@@ -679,7 +679,7 @@ void PeerMessageQueue::UpdateMetrics() {
}
void PeerMessageQueue::DumpToStrings(vector<string>* lines) const {
- boost::lock_guard<simple_spinlock> lock(queue_lock_);
+ std::lock_guard<simple_spinlock> lock(queue_lock_);
DumpToStringsUnlocked(lines);
}
@@ -696,7 +696,7 @@ void PeerMessageQueue::DumpToStringsUnlocked(vector<string>* lines) const {
void PeerMessageQueue::DumpToHtml(std::ostream& out) const {
using std::endl;
- boost::lock_guard<simple_spinlock> lock(queue_lock_);
+ std::lock_guard<simple_spinlock> lock(queue_lock_);
out << "<h3>Watermarks</h3>" << endl;
out << "<table>" << endl;;
out << " <tr><th>Peer</th><th>Watermark</th></tr>" << endl;
@@ -717,7 +717,7 @@ void PeerMessageQueue::ClearUnlocked() {
void PeerMessageQueue::Close() {
observers_pool_->Shutdown();
- boost::lock_guard<simple_spinlock> lock(queue_lock_);
+ std::lock_guard<simple_spinlock> lock(queue_lock_);
ClearUnlocked();
}
@@ -728,7 +728,7 @@ int64_t PeerMessageQueue::GetQueuedOperationsSizeBytesForTests() const {
string PeerMessageQueue::ToString() const {
// Even though metrics are thread-safe obtain the lock so that we get
// a "consistent" snapshot of the metrics.
- boost::lock_guard<simple_spinlock> lock(queue_lock_);
+ std::lock_guard<simple_spinlock> lock(queue_lock_);
return ToStringUnlocked();
}
@@ -740,7 +740,7 @@ string PeerMessageQueue::ToStringUnlocked() const {
}
void PeerMessageQueue::RegisterObserver(PeerMessageQueueObserver* observer) {
- boost::lock_guard<simple_spinlock> lock(queue_lock_);
+ std::lock_guard<simple_spinlock> lock(queue_lock_);
auto iter = std::find(observers_.begin(), observers_.end(), observer);
if (iter == observers_.end()) {
observers_.push_back(observer);
@@ -748,7 +748,7 @@ void PeerMessageQueue::RegisterObserver(PeerMessageQueueObserver* observer) {
}
Status PeerMessageQueue::UnRegisterObserver(PeerMessageQueueObserver* observer) {
- boost::lock_guard<simple_spinlock> lock(queue_lock_);
+ std::lock_guard<simple_spinlock> lock(queue_lock_);
auto iter = std::find(observers_.begin(), observers_.end(), observer);
if (iter == observers_.end()) {
return Status::NotFound("Can't find observer.");
@@ -790,7 +790,7 @@ void PeerMessageQueue::NotifyObserversOfMajorityReplOpChangeTask(
const OpId new_majority_replicated_op) {
std::vector<PeerMessageQueueObserver*> copy;
{
- boost::lock_guard<simple_spinlock> lock(queue_lock_);
+ std::lock_guard<simple_spinlock> lock(queue_lock_);
copy = observers_;
}
@@ -802,7 +802,7 @@ void PeerMessageQueue::NotifyObserversOfMajorityReplOpChangeTask(
}
{
- boost::lock_guard<simple_spinlock> lock(queue_lock_);
+ std::lock_guard<simple_spinlock> lock(queue_lock_);
if (new_committed_index.IsInitialized() &&
new_committed_index.index() > queue_state_.committed_index.index()) {
queue_state_.committed_index.CopyFrom(new_committed_index);
@@ -814,7 +814,7 @@ void PeerMessageQueue::NotifyObserversOfTermChangeTask(int64_t term) {
MAYBE_INJECT_RANDOM_LATENCY(FLAGS_consensus_inject_latency_ms_in_notifications);
std::vector<PeerMessageQueueObserver*> copy;
{
- boost::lock_guard<simple_spinlock> lock(queue_lock_);
+ std::lock_guard<simple_spinlock> lock(queue_lock_);
copy = observers_;
}
OpId new_committed_index;
@@ -838,7 +838,7 @@ void PeerMessageQueue::NotifyObserversOfFailedFollowerTask(const string& uuid,
MAYBE_INJECT_RANDOM_LATENCY(FLAGS_consensus_inject_latency_ms_in_notifications);
std::vector<PeerMessageQueueObserver*> observers_copy;
{
- boost::lock_guard<simple_spinlock> lock(queue_lock_);
+ std::lock_guard<simple_spinlock> lock(queue_lock_);
observers_copy = observers_;
}
OpId new_committed_index;
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/consensus/local_consensus.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/local_consensus.cc b/src/kudu/consensus/local_consensus.cc
index 104ebcb..2aa321e 100644
--- a/src/kudu/consensus/local_consensus.cc
+++ b/src/kudu/consensus/local_consensus.cc
@@ -17,8 +17,8 @@
#include "kudu/consensus/local_consensus.h"
-#include <boost/thread/locks.hpp>
#include <iostream>
+#include <mutex>
#include "kudu/consensus/log.h"
#include "kudu/consensus/metadata.pb.h"
@@ -60,7 +60,7 @@ Status LocalConsensus::Start(const ConsensusBootstrapInfo& info) {
LOG_WITH_PREFIX(INFO) << "Starting LocalConsensus...";
{
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
const RaftConfigPB& config = cmeta_->committed_config();
CHECK(config.local()) << "Local consensus must be passed a local config";
@@ -98,7 +98,7 @@ Status LocalConsensus::ResubmitOrphanedReplicates(const std::vector<ReplicateMsg
}
bool LocalConsensus::IsRunning() const {
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
return state_ == kRunning;
}
@@ -117,7 +117,7 @@ Status LocalConsensus::Replicate(const scoped_refptr<ConsensusRound>& round) {
LogEntryBatch* reserved_entry_batch;
{
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
// create the new op id for the entry.
cur_op_id->set_index(next_op_id_index_++);
@@ -164,12 +164,12 @@ Status LocalConsensus::RequestVote(const VoteRequestPB* request,
}
ConsensusStatePB LocalConsensus::ConsensusState(ConsensusConfigType type) const {
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
return cmeta_->ToConsensusStatePB(type);
}
RaftConfigPB LocalConsensus::CommittedConfig() const {
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
return cmeta_->committed_config();
}
@@ -180,7 +180,7 @@ void LocalConsensus::Shutdown() {
void LocalConsensus::DumpStatusHtml(std::ostream& out) const {
out << "<h1>Local Consensus Status</h1>\n";
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
out << "next op: " << next_op_id_index_;
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/consensus/local_consensus.h
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/local_consensus.h b/src/kudu/consensus/local_consensus.h
index 9e5f799..db9db04 100644
--- a/src/kudu/consensus/local_consensus.h
+++ b/src/kudu/consensus/local_consensus.h
@@ -17,7 +17,6 @@
#ifndef KUDU_CONSENSUS_LOCAL_CONSENSUS_H_
#define KUDU_CONSENSUS_LOCAL_CONSENSUS_H_
-#include <boost/thread/locks.hpp>
#include <string>
#include <vector>
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/consensus/log.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/log.cc b/src/kudu/consensus/log.cc
index 7987304..62eca2b 100644
--- a/src/kudu/consensus/log.cc
+++ b/src/kudu/consensus/log.cc
@@ -18,6 +18,8 @@
#include "kudu/consensus/log.h"
#include <algorithm>
+#include <boost/thread/shared_mutex.hpp>
+#include <mutex>
#include "kudu/common/wire_protocol.h"
#include "kudu/consensus/log_index.h"
@@ -138,7 +140,7 @@ class Log::AppendThread {
Log* const log_;
// Lock to protect access to thread_ during shutdown.
- mutable boost::mutex lock_;
+ mutable std::mutex lock_;
scoped_refptr<Thread> thread_;
};
@@ -233,7 +235,7 @@ void Log::AppendThread::RunThread() {
void Log::AppendThread::Shutdown() {
log_->entry_queue()->Shutdown();
- boost::lock_guard<boost::mutex> lock_guard(lock_);
+ std::lock_guard<std::mutex> lock_guard(lock_);
if (thread_) {
VLOG(1) << "Shutting down log append thread for tablet " << log_->tablet_id();
CHECK_OK(ThreadJoiner(thread_.get()).Join());
@@ -301,7 +303,7 @@ Log::Log(LogOptions options, FsManager* fs_manager, string log_path,
}
Status Log::Init() {
- boost::lock_guard<percpu_rwlock> write_lock(state_lock_);
+ std::lock_guard<percpu_rwlock> write_lock(state_lock_);
CHECK_EQ(kLogInitialized, log_state_);
// Init the index
@@ -343,7 +345,7 @@ Status Log::Init() {
}
Status Log::AsyncAllocateSegment() {
- boost::lock_guard<boost::shared_mutex> lock_guard(allocation_lock_);
+ std::lock_guard<boost::shared_mutex> lock_guard(allocation_lock_);
CHECK_EQ(allocation_state_, kAllocationNotStarted);
allocation_status_.Reset();
allocation_state_ = kAllocationInProgress;
@@ -486,7 +488,7 @@ Status Log::DoAppend(LogEntryBatch* entry_batch, bool caller_owns_operation) {
// is not the last durable operation. Either move this to tablet peer (since we're
// using in flights anyway no need to scan for ids here) or actually delay doing this
// until fsync() has been done. See KUDU-527.
- boost::lock_guard<rw_spinlock> write_lock(last_entry_op_id_lock_);
+ std::lock_guard<rw_spinlock> write_lock(last_entry_op_id_lock_);
last_entry_op_id_.CopyFrom(entry_batch->MaxReplicateOpId());
}
@@ -706,7 +708,7 @@ Status Log::GC(int64_t min_op_idx, int32_t* num_gced) {
SegmentSequence segments_to_delete;
{
- boost::lock_guard<percpu_rwlock> l(state_lock_);
+ std::lock_guard<percpu_rwlock> l(state_lock_);
CHECK_EQ(kLogWriting, log_state_);
GetSegmentsToGCUnlocked(min_op_idx, &segments_to_delete);
@@ -778,7 +780,7 @@ void Log::GetMaxIndexesToSegmentSizeMap(int64_t min_op_idx,
void Log::SetSchemaForNextLogSegment(const Schema& schema,
uint32_t version) {
- boost::lock_guard<rw_spinlock> l(schema_lock_);
+ std::lock_guard<rw_spinlock> l(schema_lock_);
schema_ = schema;
schema_version_ = version;
}
@@ -787,7 +789,7 @@ Status Log::Close() {
allocation_pool_->Shutdown();
append_thread_->Shutdown();
- boost::lock_guard<percpu_rwlock> l(state_lock_);
+ std::lock_guard<percpu_rwlock> l(state_lock_);
switch (log_state_) {
case kLogWriting:
if (log_hooks_) {
@@ -846,7 +848,7 @@ Status Log::PreAllocateNewSegment() {
}
{
- boost::lock_guard<boost::shared_mutex> lock_guard(allocation_lock_);
+ std::lock_guard<boost::shared_mutex> lock_guard(allocation_lock_);
allocation_state_ = kAllocationFinished;
}
return Status::OK();
@@ -895,7 +897,7 @@ Status Log::SwitchToAllocatedSegment() {
// need to be able to replay the segments for other peers.
{
if (active_segment_.get() != nullptr) {
- boost::lock_guard<percpu_rwlock> l(state_lock_);
+ std::lock_guard<percpu_rwlock> l(state_lock_);
CHECK_OK(ReplaceSegmentInReaderUnlocked());
}
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/consensus/log_anchor_registry.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/log_anchor_registry.cc b/src/kudu/consensus/log_anchor_registry.cc
index 0ad9a7d..017ef79 100644
--- a/src/kudu/consensus/log_anchor_registry.cc
+++ b/src/kudu/consensus/log_anchor_registry.cc
@@ -18,7 +18,7 @@
#include "kudu/consensus/log_anchor_registry.h"
#include "kudu/consensus/opid_util.h"
-#include <boost/thread/locks.hpp>
+#include <mutex>
#include <string>
#include "kudu/gutil/strings/substitute.h"
@@ -42,14 +42,14 @@ LogAnchorRegistry::~LogAnchorRegistry() {
void LogAnchorRegistry::Register(int64_t log_index,
const string& owner,
LogAnchor* anchor) {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
RegisterUnlocked(log_index, owner, anchor);
}
Status LogAnchorRegistry::UpdateRegistration(int64_t log_index,
const std::string& owner,
LogAnchor* anchor) {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
RETURN_NOT_OK_PREPEND(UnregisterUnlocked(anchor),
"Unable to swap registration, anchor not registered")
RegisterUnlocked(log_index, owner, anchor);
@@ -57,18 +57,18 @@ Status LogAnchorRegistry::UpdateRegistration(int64_t log_index,
}
Status LogAnchorRegistry::Unregister(LogAnchor* anchor) {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
return UnregisterUnlocked(anchor);
}
Status LogAnchorRegistry::UnregisterIfAnchored(LogAnchor* anchor) {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
if (!anchor->is_registered) return Status::OK();
return UnregisterUnlocked(anchor);
}
Status LogAnchorRegistry::GetEarliestRegisteredLogIndex(int64_t* log_index) {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
auto iter = anchors_.begin();
if (iter == anchors_.end()) {
return Status::NotFound("No anchors in registry");
@@ -80,13 +80,13 @@ Status LogAnchorRegistry::GetEarliestRegisteredLogIndex(int64_t* log_index) {
}
size_t LogAnchorRegistry::GetAnchorCountForTests() const {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
return anchors_.size();
}
std::string LogAnchorRegistry::DumpAnchorInfo() const {
string buf;
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
MonoTime now = MonoTime::Now(MonoTime::FINE);
for (const AnchorMultiMap::value_type& entry : anchors_) {
const LogAnchor* anchor = entry.second;
@@ -153,7 +153,7 @@ MinLogIndexAnchorer::~MinLogIndexAnchorer() {
}
void MinLogIndexAnchorer::AnchorIfMinimum(int64_t log_index) {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
if (PREDICT_FALSE(minimum_log_index_ == kInvalidOpIdIndex)) {
minimum_log_index_ = log_index;
registry_->Register(minimum_log_index_, owner_, &anchor_);
@@ -164,7 +164,7 @@ void MinLogIndexAnchorer::AnchorIfMinimum(int64_t log_index) {
}
Status MinLogIndexAnchorer::ReleaseAnchor() {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
if (PREDICT_TRUE(minimum_log_index_ != kInvalidOpIdIndex)) {
return registry_->Unregister(&anchor_);
}
@@ -172,7 +172,7 @@ Status MinLogIndexAnchorer::ReleaseAnchor() {
}
int64_t MinLogIndexAnchorer::minimum_log_index() const {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
return minimum_log_index_;
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/consensus/log_reader.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/log_reader.cc b/src/kudu/consensus/log_reader.cc
index c7d001d..c1ee1eb 100644
--- a/src/kudu/consensus/log_reader.cc
+++ b/src/kudu/consensus/log_reader.cc
@@ -17,8 +17,8 @@
#include "kudu/consensus/log_reader.h"
-#include <boost/thread/locks.hpp>
#include <algorithm>
+#include <mutex>
#include "kudu/consensus/log_index.h"
#include "kudu/consensus/opid_util.h"
@@ -118,7 +118,7 @@ LogReader::~LogReader() {
Status LogReader::Init(const string& tablet_wal_path) {
{
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
CHECK_EQ(state_, kLogReaderInitialized) << "bad state for Init(): " << state_;
}
VLOG(1) << "Reading wal from path:" << tablet_wal_path;
@@ -163,7 +163,7 @@ Status LogReader::Init(const string& tablet_wal_path) {
{
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
string previous_seg_path;
int64_t previous_seg_seqno = -1;
@@ -189,7 +189,7 @@ Status LogReader::Init(const string& tablet_wal_path) {
}
Status LogReader::InitEmptyReaderForTests() {
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
state_ = kLogReaderReading;
return Status::OK();
}
@@ -200,7 +200,7 @@ Status LogReader::GetSegmentPrefixNotIncluding(int64_t index,
DCHECK(segments);
segments->clear();
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
CHECK_EQ(state_, kLogReaderReading);
for (const scoped_refptr<ReadableLogSegment>& segment : segments_) {
@@ -219,7 +219,7 @@ Status LogReader::GetSegmentPrefixNotIncluding(int64_t index,
}
int64_t LogReader::GetMinReplicateIndex() const {
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
int64_t min_remaining_op_idx = -1;
for (const scoped_refptr<ReadableLogSegment>& segment : segments_) {
@@ -237,7 +237,7 @@ void LogReader::GetMaxIndexesToSegmentSizeMap(int64_t min_op_idx, int32_t segmen
int64_t max_close_time_us,
std::map<int64_t, int64_t>*
max_idx_to_segment_size) const {
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
DCHECK_GE(segments_count, 0);
for (const scoped_refptr<ReadableLogSegment>& segment : segments_) {
if (max_idx_to_segment_size->size() == segments_count) {
@@ -261,7 +261,7 @@ void LogReader::GetMaxIndexesToSegmentSizeMap(int64_t min_op_idx, int32_t segmen
}
scoped_refptr<ReadableLogSegment> LogReader::GetSegmentBySequenceNumber(int64_t seq) const {
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
if (segments_.empty()) {
return nullptr;
}
@@ -395,14 +395,14 @@ Status LogReader::LookupOpId(int64_t op_index, OpId* op_id) const {
}
Status LogReader::GetSegmentsSnapshot(SegmentSequence* segments) const {
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
CHECK_EQ(state_, kLogReaderReading);
segments->assign(segments_.begin(), segments_.end());
return Status::OK();
}
Status LogReader::TrimSegmentsUpToAndIncluding(int64_t segment_sequence_number) {
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
CHECK_EQ(state_, kLogReaderReading);
auto iter = segments_.begin();
int num_deleted_segments = 0;
@@ -421,7 +421,7 @@ Status LogReader::TrimSegmentsUpToAndIncluding(int64_t segment_sequence_number)
}
void LogReader::UpdateLastSegmentOffset(int64_t readable_to_offset) {
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
CHECK_EQ(state_, kLogReaderReading);
DCHECK(!segments_.empty());
// Get the last segment
@@ -435,7 +435,7 @@ Status LogReader::ReplaceLastSegment(const scoped_refptr<ReadableLogSegment>& se
// have a footer.
DCHECK(segment->HasFooter());
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
CHECK_EQ(state_, kLogReaderReading);
// Make sure the segment we're replacing has the same sequence number
CHECK(!segments_.empty());
@@ -450,7 +450,7 @@ Status LogReader::AppendSegment(const scoped_refptr<ReadableLogSegment>& segment
if (PREDICT_FALSE(!segment->HasFooter())) {
RETURN_NOT_OK(segment->RebuildFooterByScanning());
}
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
return AppendSegmentUnlocked(segment);
}
@@ -468,7 +468,7 @@ Status LogReader::AppendSegmentUnlocked(const scoped_refptr<ReadableLogSegment>&
Status LogReader::AppendEmptySegment(const scoped_refptr<ReadableLogSegment>& segment) {
DCHECK(segment->IsInitialized());
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
CHECK_EQ(state_, kLogReaderReading);
if (!segments_.empty()) {
CHECK_EQ(segments_.back()->header().sequence_number() + 1,
@@ -479,12 +479,12 @@ Status LogReader::AppendEmptySegment(const scoped_refptr<ReadableLogSegment>& se
}
const int LogReader::num_segments() const {
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
return segments_.size();
}
string LogReader::ToString() const {
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
string ret = "Reader's SegmentSequence: \n";
for (const SegmentSequence::value_type& entry : segments_) {
ret.append(Substitute("Segment: $0 Footer: $1\n",
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/consensus/mt-log-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/mt-log-test.cc b/src/kudu/consensus/mt-log-test.cc
index 94921e7..7f590e2 100644
--- a/src/kudu/consensus/mt-log-test.cc
+++ b/src/kudu/consensus/mt-log-test.cc
@@ -17,11 +17,9 @@
#include "kudu/consensus/log-test-base.h"
-#include <boost/thread/locks.hpp>
-#include <boost/thread/mutex.hpp>
-
#include <algorithm>
#include <memory>
+#include <mutex>
#include <vector>
#include "kudu/consensus/log_index.h"
@@ -93,7 +91,7 @@ class MultiThreadedLogTest : public LogTestBase {
DVLOG(1) << num_ops << " ops in this batch";
num_ops = std::max(num_ops, 1);
{
- boost::lock_guard<simple_spinlock> lock_guard(lock_);
+ std::lock_guard<simple_spinlock> lock_guard(lock_);
for (int j = 0; j < num_ops; j++) {
ReplicateRefPtr replicate = make_scoped_refptr_replicate(new ReplicateMsg);
int32_t index = current_index_++;
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/consensus/peer_manager.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/peer_manager.cc b/src/kudu/consensus/peer_manager.cc
index 4acbac7..cb7df2f 100644
--- a/src/kudu/consensus/peer_manager.cc
+++ b/src/kudu/consensus/peer_manager.cc
@@ -17,6 +17,8 @@
#include "kudu/consensus/peer_manager.h"
+#include <mutex>
+
#include "kudu/consensus/consensus_peers.h"
#include "kudu/consensus/log.h"
#include "kudu/gutil/map-util.h"
@@ -53,7 +55,7 @@ Status PeerManager::UpdateRaftConfig(const RaftConfigPB& config) {
VLOG(1) << "Updating peers from new config: " << config.ShortDebugString();
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
// Create new peers
for (const RaftPeerPB& peer_pb : config.peers()) {
new_peers.insert(peer_pb.permanent_uuid());
@@ -85,7 +87,7 @@ Status PeerManager::UpdateRaftConfig(const RaftConfigPB& config) {
}
void PeerManager::SignalRequest(bool force_if_queue_empty) {
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
auto iter = peers_.begin();
for (; iter != peers_.end(); iter++) {
Status s = (*iter).second->SignalRequest(force_if_queue_empty);
@@ -100,7 +102,7 @@ void PeerManager::SignalRequest(bool force_if_queue_empty) {
void PeerManager::Close() {
{
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
for (const PeersMap::value_type& entry : peers_) {
entry.second->Close();
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/consensus/raft_consensus.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/raft_consensus.cc b/src/kudu/consensus/raft_consensus.cc
index b23087a..710075a 100644
--- a/src/kudu/consensus/raft_consensus.cc
+++ b/src/kudu/consensus/raft_consensus.cc
@@ -21,6 +21,7 @@
#include <boost/optional.hpp>
#include <gflags/gflags.h>
#include <iostream>
+#include <mutex>
#include "kudu/common/wire_protocol.h"
#include "kudu/consensus/consensus.pb.h"
@@ -499,7 +500,7 @@ Status RaftConsensus::Replicate(const scoped_refptr<ConsensusRound>& round) {
RETURN_NOT_OK(ExecuteHook(PRE_REPLICATE));
- boost::lock_guard<simple_spinlock> lock(update_lock_);
+ std::lock_guard<simple_spinlock> lock(update_lock_);
{
ReplicaState::UniqueLock lock;
RETURN_NOT_OK(state_->LockForReplicate(&lock, *round->replicate_msg()));
@@ -669,7 +670,7 @@ Status RaftConsensus::Update(const ConsensusRequestPB* request,
VLOG_WITH_PREFIX(2) << "Replica received request: " << request->ShortDebugString();
// see var declaration
- boost::lock_guard<simple_spinlock> lock(update_lock_);
+ std::lock_guard<simple_spinlock> lock(update_lock_);
Status s = UpdateReplica(request, response);
if (PREDICT_FALSE(VLOG_IS_ON(1))) {
if (request->ops_size() == 0) {
@@ -1267,7 +1268,7 @@ Status RaftConsensus::RequestVote(const VoteRequestPB* request, VoteResponsePB*
// We must acquire the update lock in order to ensure that this vote action
// takes place between requests.
// Lock ordering: The update lock must be acquired before the ReplicaState lock.
- boost::unique_lock<simple_spinlock> update_guard(update_lock_, boost::defer_lock);
+ std::unique_lock<simple_spinlock> update_guard(update_lock_, std::defer_lock);
if (FLAGS_enable_leader_failure_detection) {
update_guard.try_lock();
} else {
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/consensus/raft_consensus.h
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/raft_consensus.h b/src/kudu/consensus/raft_consensus.h
index 6f5e377..2864ff3 100644
--- a/src/kudu/consensus/raft_consensus.h
+++ b/src/kudu/consensus/raft_consensus.h
@@ -18,8 +18,9 @@
#ifndef KUDU_CONSENSUS_RAFT_CONSENSUS_H_
#define KUDU_CONSENSUS_RAFT_CONSENSUS_H_
-#include <boost/thread/locks.hpp>
+#include <boost/optional/optional_fwd.hpp>
#include <memory>
+#include <mutex>
#include <string>
#include <utility>
#include <vector>
@@ -33,7 +34,7 @@
namespace kudu {
-typedef boost::lock_guard<simple_spinlock> Lock;
+typedef std::lock_guard<simple_spinlock> Lock;
typedef gscoped_ptr<Lock> ScopedLock;
class Counter;
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/experiments/rwlock-perf.cc
----------------------------------------------------------------------
diff --git a/src/kudu/experiments/rwlock-perf.cc b/src/kudu/experiments/rwlock-perf.cc
index 175aaa3..a559c6b 100644
--- a/src/kudu/experiments/rwlock-perf.cc
+++ b/src/kudu/experiments/rwlock-perf.cc
@@ -16,10 +16,10 @@
// under the License.
#include <boost/smart_ptr/detail/spinlock.hpp>
-#include <boost/thread/mutex.hpp>
#include <boost/thread/shared_mutex.hpp>
#include <gflags/gflags.h>
#include <glog/logging.h>
+#include <mutex>
#include <stdio.h>
#include <thread>
#include <unistd.h>
@@ -82,7 +82,7 @@ struct shared_data {
kudu::rw_spinlock rw_spinlock;
boost::shared_mutex rwlock;
- boost::mutex lock;
+ std::mutex lock;
kudu::percpu_rwlock per_cpu;
};
@@ -191,7 +191,7 @@ void test_shared_lock(int num_threads, TestMethod method, const char *name) {
threads.emplace_back(shared_mutex_entry, &shared);
break;
case OWN_MUTEX:
- threads.emplace_back(own_mutex_entry<boost::mutex>);
+ threads.emplace_back(own_mutex_entry<std::mutex>);
break;
case OWN_SPINLOCK:
threads.emplace_back(own_mutex_entry<my_spinlock>);
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/master/catalog_manager.cc
----------------------------------------------------------------------
diff --git a/src/kudu/master/catalog_manager.cc b/src/kudu/master/catalog_manager.cc
index aac64d8..30f0cc2 100644
--- a/src/kudu/master/catalog_manager.cc
+++ b/src/kudu/master/catalog_manager.cc
@@ -41,14 +41,13 @@
#include "kudu/master/catalog_manager.h"
+#include <algorithm>
#include <boost/optional.hpp>
-#include <boost/thread/condition_variable.hpp>
-#include <boost/thread/locks.hpp>
-#include <boost/thread/mutex.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <condition_variable>
#include <glog/logging.h>
-
-#include <algorithm>
#include <memory>
+#include <mutex>
#include <set>
#include <string>
#include <utility>
@@ -548,7 +547,7 @@ CatalogManager::~CatalogManager() {
Status CatalogManager::Init(bool is_first_run) {
{
- boost::lock_guard<simple_spinlock> l(state_lock_);
+ std::lock_guard<simple_spinlock> l(state_lock_);
CHECK_EQ(kConstructed, state_);
state_ = kStarting;
}
@@ -564,13 +563,13 @@ Status CatalogManager::Init(bool is_first_run) {
RETURN_NOT_OK_PREPEND(sys_catalog_->WaitUntilRunning(),
"Failed waiting for the catalog tablet to run");
- boost::lock_guard<LockType> l(lock_);
+ std::lock_guard<LockType> l(lock_);
background_tasks_.reset(new CatalogManagerBgTasks(this));
RETURN_NOT_OK_PREPEND(background_tasks_->Init(),
"Failed to initialize catalog manager background tasks");
{
- boost::lock_guard<simple_spinlock> l(state_lock_);
+ std::lock_guard<simple_spinlock> l(state_lock_);
CHECK_EQ(kStarting, state_);
state_ = kRunning;
}
@@ -579,7 +578,7 @@ Status CatalogManager::Init(bool is_first_run) {
}
Status CatalogManager::ElectedAsLeaderCb() {
- boost::lock_guard<simple_spinlock> l(state_lock_);
+ std::lock_guard<simple_spinlock> l(state_lock_);
return worker_pool_->SubmitClosure(
Bind(&CatalogManager::VisitTablesAndTabletsTask, Unretained(this)));
}
@@ -616,7 +615,7 @@ void CatalogManager::VisitTablesAndTabletsTask() {
}
{
- boost::lock_guard<LockType> lock(lock_);
+ std::lock_guard<LockType> lock(lock_);
int64_t term_after_wait = consensus->ConsensusState(CONSENSUS_CONFIG_COMMITTED).current_term();
if (term_after_wait != term) {
// If we got elected leader again while waiting to catch up then we will
@@ -631,7 +630,7 @@ void CatalogManager::VisitTablesAndTabletsTask() {
CHECK_OK(VisitTablesAndTabletsUnlocked());
}
}
- boost::lock_guard<simple_spinlock> l(state_lock_);
+ std::lock_guard<simple_spinlock> l(state_lock_);
leader_ready_term_ = term;
}
@@ -654,7 +653,7 @@ Status CatalogManager::VisitTablesAndTabletsUnlocked() {
}
Status CatalogManager::InitSysCatalogAsync(bool is_first_run) {
- boost::lock_guard<LockType> l(lock_);
+ std::lock_guard<LockType> l(lock_);
sys_catalog_.reset(new SysCatalogTable(master_,
master_->metric_registry(),
Bind(&CatalogManager::ElectedAsLeaderCb,
@@ -668,12 +667,12 @@ Status CatalogManager::InitSysCatalogAsync(bool is_first_run) {
}
bool CatalogManager::IsInitialized() const {
- boost::lock_guard<simple_spinlock> l(state_lock_);
+ std::lock_guard<simple_spinlock> l(state_lock_);
return state_ == kRunning;
}
Status CatalogManager::CheckIsLeaderAndReady() const {
- boost::lock_guard<simple_spinlock> l(state_lock_);
+ std::lock_guard<simple_spinlock> l(state_lock_);
if (PREDICT_FALSE(state_ != kRunning)) {
return Status::ServiceUnavailable(
Substitute("Catalog manager is shutting down. State: $0", state_));
@@ -699,7 +698,7 @@ RaftPeerPB::Role CatalogManager::Role() const {
void CatalogManager::Shutdown() {
{
- boost::lock_guard<simple_spinlock> l(state_lock_);
+ std::lock_guard<simple_spinlock> l(state_lock_);
if (state_ == kClosing) {
VLOG(2) << "CatalogManager already shut down";
return;
@@ -720,7 +719,7 @@ void CatalogManager::Shutdown() {
// any new tasks for those entries.
TableInfoMap copy;
{
- boost::lock_guard<simple_spinlock> l(state_lock_);
+ std::lock_guard<simple_spinlock> l(state_lock_);
copy = table_ids_map_;
}
for (const TableInfoMap::value_type &e : copy) {
@@ -866,7 +865,7 @@ Status CatalogManager::CreateTable(const CreateTableRequestPB* orig_req,
scoped_refptr<TableInfo> table;
{
- boost::lock_guard<LockType> l(lock_);
+ std::lock_guard<LockType> l(lock_);
TRACE("Acquired catalog manager lock");
// b. Verify that the table does not exist.
@@ -887,7 +886,7 @@ Status CatalogManager::CreateTable(const CreateTableRequestPB* orig_req,
// Ensure that if we return, we mark this table as no longer being created.
auto cleanup = MakeScopedCleanup([&] () {
- boost::lock_guard<LockType> l(lock_);
+ std::lock_guard<LockType> l(lock_);
CHECK_EQ(1, tables_being_created_.erase(req.name()));
});
@@ -939,7 +938,7 @@ Status CatalogManager::CreateTable(const CreateTableRequestPB* orig_req,
// g. Make the new table and tablets visible in the catalog.
{
- boost::lock_guard<LockType> l(lock_);
+ std::lock_guard<LockType> l(lock_);
table_ids_map_[table->id()] = table;
table_names_map_[req.name()] = table;
@@ -1091,7 +1090,7 @@ Status CatalogManager::DeleteTable(const DeleteTableRequestPB* req,
// 4. Remove the table from the by-name map.
{
TRACE("Removing table from by-name map");
- boost::lock_guard<LockType> l_map(lock_);
+ std::lock_guard<LockType> l_map(lock_);
if (table_names_map_.erase(l.data().name()) != 1) {
PANIC_RPC(rpc, "Could not remove table from map, name=" + l.data().name());
}
@@ -1248,7 +1247,7 @@ Status CatalogManager::AlterTable(const AlterTableRequestPB* req,
// 3. Try to acquire the new table name
if (req->has_new_table_name()) {
- boost::lock_guard<LockType> catalog_lock(lock_);
+ std::lock_guard<LockType> catalog_lock(lock_);
TRACE("Acquired catalog manager lock");
@@ -1297,7 +1296,7 @@ Status CatalogManager::AlterTable(const AlterTableRequestPB* req,
s.ToString()));
LOG(WARNING) << s.ToString();
if (req->has_new_table_name()) {
- boost::lock_guard<LockType> catalog_lock(lock_);
+ std::lock_guard<LockType> catalog_lock(lock_);
CHECK_EQ(table_names_map_.erase(req->new_table_name()), 1);
}
CheckIfNoLongerLeaderAndSetupError(s, resp);
@@ -1307,7 +1306,7 @@ Status CatalogManager::AlterTable(const AlterTableRequestPB* req,
// 6. Remove the old name
if (req->has_new_table_name()) {
TRACE("Removing old-name $0 from by-name map", table_name);
- boost::lock_guard<LockType> l_map(lock_);
+ std::lock_guard<LockType> l_map(lock_);
if (table_names_map_.erase(table_name) != 1) {
PANIC_RPC(rpc, "Could not remove table from map, name=" + l.data().name());
}
@@ -2814,7 +2813,7 @@ Status CatalogManager::ProcessPendingAssignments(
unlocker_out.Commit();
unlocker_in.Commit();
{
- boost::lock_guard<LockType> l(lock_);
+ std::lock_guard<LockType> l(lock_);
for (const auto& new_tablet : unlocker_out) {
new_tablet->table()->AddTablet(new_tablet.get());
tablet_map_[new_tablet->tablet_id()] = new_tablet;
@@ -3204,33 +3203,33 @@ TabletInfo::~TabletInfo() {
}
void TabletInfo::SetReplicaLocations(const ReplicaMap& replica_locations) {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
last_update_time_ = MonoTime::Now(MonoTime::FINE);
replica_locations_ = replica_locations;
}
void TabletInfo::GetReplicaLocations(ReplicaMap* replica_locations) const {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
*replica_locations = replica_locations_;
}
bool TabletInfo::AddToReplicaLocations(const TabletReplica& replica) {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
return InsertIfNotPresent(&replica_locations_, replica.ts_desc->permanent_uuid(), replica);
}
void TabletInfo::set_last_update_time(const MonoTime& ts) {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
last_update_time_ = ts;
}
MonoTime TabletInfo::last_update_time() const {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
return last_update_time_;
}
bool TabletInfo::set_reported_schema_version(uint32_t version) {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
if (version > reported_schema_version_) {
reported_schema_version_ = version;
return true;
@@ -3239,7 +3238,7 @@ bool TabletInfo::set_reported_schema_version(uint32_t version) {
}
uint32_t TabletInfo::reported_schema_version() const {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
return reported_schema_version_;
}
@@ -3268,17 +3267,17 @@ std::string TableInfo::ToString() const {
}
bool TableInfo::RemoveTablet(const std::string& partition_key_start) {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
return EraseKeyReturnValuePtr(&tablet_map_, partition_key_start) != NULL;
}
void TableInfo::AddTablet(TabletInfo *tablet) {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
AddTabletUnlocked(tablet);
}
void TableInfo::AddTablets(const vector<TabletInfo*>& tablets) {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
for (TabletInfo *tablet : tablets) {
AddTabletUnlocked(tablet);
}
@@ -3298,7 +3297,7 @@ void TableInfo::AddTabletUnlocked(TabletInfo* tablet) {
void TableInfo::GetTabletsInRange(const GetTableLocationsRequestPB* req,
vector<scoped_refptr<TabletInfo> > *ret) const {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
int max_returned_locations = req->max_returned_locations();
TableInfo::TabletInfoMap::const_iterator it, it_end;
@@ -3325,7 +3324,7 @@ void TableInfo::GetTabletsInRange(const GetTableLocationsRequestPB* req,
}
bool TableInfo::IsAlterInProgress(uint32_t version) const {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
for (const TableInfo::TabletInfoMap::value_type& e : tablet_map_) {
if (e.second->reported_schema_version() < version) {
VLOG(3) << "Table " << table_id_ << " ALTER in progress due to tablet "
@@ -3338,7 +3337,7 @@ bool TableInfo::IsAlterInProgress(uint32_t version) const {
}
bool TableInfo::IsCreateInProgress() const {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
for (const TableInfo::TabletInfoMap::value_type& e : tablet_map_) {
TabletMetadataLock tablet_lock(e.second, TabletMetadataLock::READ);
if (!tablet_lock.data().is_running()) {
@@ -3349,19 +3348,19 @@ bool TableInfo::IsCreateInProgress() const {
}
void TableInfo::AddTask(MonitoredTask* task) {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
task->AddRef();
pending_tasks_.insert(task);
}
void TableInfo::RemoveTask(MonitoredTask* task) {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
pending_tasks_.erase(task);
task->Release();
}
void TableInfo::AbortTasks() {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
for (MonitoredTask* task : pending_tasks_) {
task->Abort();
}
@@ -3371,7 +3370,7 @@ void TableInfo::WaitTasksCompletion() {
int wait_time = 5;
while (1) {
{
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
if (pending_tasks_.empty()) {
break;
}
@@ -3382,7 +3381,7 @@ void TableInfo::WaitTasksCompletion() {
}
void TableInfo::GetTaskList(std::vector<scoped_refptr<MonitoredTask> > *ret) {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
for (MonitoredTask* task : pending_tasks_) {
ret->push_back(make_scoped_refptr(task));
}
@@ -3390,7 +3389,7 @@ void TableInfo::GetTaskList(std::vector<scoped_refptr<MonitoredTask> > *ret) {
void TableInfo::GetAllTablets(vector<scoped_refptr<TabletInfo> > *ret) const {
ret->clear();
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
for (const TableInfo::TabletInfoMap::value_type& e : tablet_map_) {
ret->push_back(make_scoped_refptr(e.second));
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/master/catalog_manager.h
----------------------------------------------------------------------
diff --git a/src/kudu/master/catalog_manager.h b/src/kudu/master/catalog_manager.h
index a4e07a3..daf1feb 100644
--- a/src/kudu/master/catalog_manager.h
+++ b/src/kudu/master/catalog_manager.h
@@ -18,7 +18,6 @@
#define KUDU_MASTER_CATALOG_MANAGER_H
#include <boost/optional/optional_fwd.hpp>
-#include <boost/thread/mutex.hpp>
#include <map>
#include <set>
#include <string>
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/master/ts_descriptor.cc
----------------------------------------------------------------------
diff --git a/src/kudu/master/ts_descriptor.cc b/src/kudu/master/ts_descriptor.cc
index 7dbf5cc..1e5434b 100644
--- a/src/kudu/master/ts_descriptor.cc
+++ b/src/kudu/master/ts_descriptor.cc
@@ -15,20 +15,19 @@
// specific language governing permissions and limitations
// under the License.
+#include "kudu/master/ts_descriptor.h"
+
+#include <math.h>
+#include <mutex>
+#include <vector>
+
#include "kudu/common/wire_protocol.h"
#include "kudu/consensus/consensus.proxy.h"
#include "kudu/gutil/strings/substitute.h"
-#include "kudu/master/ts_descriptor.h"
#include "kudu/master/master.pb.h"
#include "kudu/tserver/tserver_admin.proxy.h"
#include "kudu/util/net/net_util.h"
-#include <boost/thread/locks.hpp>
-#include <boost/thread/mutex.hpp>
-
-#include <math.h>
-#include <vector>
-
using std::shared_ptr;
namespace kudu {
@@ -58,7 +57,7 @@ TSDescriptor::~TSDescriptor() {
Status TSDescriptor::Register(const NodeInstancePB& instance,
const TSRegistrationPB& registration) {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
CHECK_EQ(instance.permanent_uuid(), permanent_uuid_);
// TODO(KUDU-418): we don't currently support changing IPs or hosts since the
@@ -99,28 +98,28 @@ Status TSDescriptor::Register(const NodeInstancePB& instance,
}
void TSDescriptor::UpdateHeartbeatTime() {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
last_heartbeat_ = MonoTime::Now(MonoTime::FINE);
}
MonoDelta TSDescriptor::TimeSinceHeartbeat() const {
MonoTime now(MonoTime::Now(MonoTime::FINE));
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
return now.GetDeltaSince(last_heartbeat_);
}
int64_t TSDescriptor::latest_seqno() const {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
return latest_seqno_;
}
bool TSDescriptor::has_tablet_report() const {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
return has_tablet_report_;
}
void TSDescriptor::set_has_tablet_report(bool has_report) {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
has_tablet_report_ = has_report;
}
@@ -148,19 +147,19 @@ void TSDescriptor::IncrementRecentReplicaCreations() {
}
double TSDescriptor::RecentReplicaCreations() {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
DecayRecentReplicaCreationsUnlocked();
return recent_replica_creations_;
}
void TSDescriptor::GetRegistration(TSRegistrationPB* reg) const {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
CHECK(registration_) << "No registration";
CHECK_NOTNULL(reg)->CopyFrom(*registration_);
}
void TSDescriptor::GetNodeInstancePB(NodeInstancePB* instance_pb) const {
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
instance_pb->set_permanent_uuid(permanent_uuid_);
instance_pb->set_instance_seqno(latest_seqno_);
}
@@ -168,7 +167,7 @@ void TSDescriptor::GetNodeInstancePB(NodeInstancePB* instance_pb) const {
Status TSDescriptor::ResolveSockaddr(Sockaddr* addr) const {
vector<HostPort> hostports;
{
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
for (const HostPortPB& addr : registration_->rpc_addresses()) {
hostports.push_back(HostPort(addr.host(), addr.port()));
}
@@ -201,7 +200,7 @@ Status TSDescriptor::ResolveSockaddr(Sockaddr* addr) const {
Status TSDescriptor::GetTSAdminProxy(const shared_ptr<rpc::Messenger>& messenger,
shared_ptr<tserver::TabletServerAdminServiceProxy>* proxy) {
{
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
if (ts_admin_proxy_) {
*proxy = ts_admin_proxy_;
return Status::OK();
@@ -211,7 +210,7 @@ Status TSDescriptor::GetTSAdminProxy(const shared_ptr<rpc::Messenger>& messenger
Sockaddr addr;
RETURN_NOT_OK(ResolveSockaddr(&addr));
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
if (!ts_admin_proxy_) {
ts_admin_proxy_.reset(new tserver::TabletServerAdminServiceProxy(messenger, addr));
}
@@ -222,7 +221,7 @@ Status TSDescriptor::GetTSAdminProxy(const shared_ptr<rpc::Messenger>& messenger
Status TSDescriptor::GetConsensusProxy(const shared_ptr<rpc::Messenger>& messenger,
shared_ptr<consensus::ConsensusServiceProxy>* proxy) {
{
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
if (consensus_proxy_) {
*proxy = consensus_proxy_;
return Status::OK();
@@ -232,7 +231,7 @@ Status TSDescriptor::GetConsensusProxy(const shared_ptr<rpc::Messenger>& messeng
Sockaddr addr;
RETURN_NOT_OK(ResolveSockaddr(&addr));
- boost::lock_guard<simple_spinlock> l(lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
if (!consensus_proxy_) {
consensus_proxy_.reset(new consensus::ConsensusServiceProxy(messenger, addr));
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/master/ts_manager.cc
----------------------------------------------------------------------
diff --git a/src/kudu/master/ts_manager.cc b/src/kudu/master/ts_manager.cc
index 1b5e140..ee8761f 100644
--- a/src/kudu/master/ts_manager.cc
+++ b/src/kudu/master/ts_manager.cc
@@ -17,8 +17,8 @@
#include "kudu/master/ts_manager.h"
-#include <boost/thread/locks.hpp>
-#include <boost/thread/mutex.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <mutex>
#include <vector>
#include "kudu/gutil/map-util.h"
@@ -72,7 +72,7 @@ bool TSManager::LookupTSByUUID(const string& uuid,
Status TSManager::RegisterTS(const NodeInstancePB& instance,
const TSRegistrationPB& registration,
std::shared_ptr<TSDescriptor>* desc) {
- boost::lock_guard<rw_spinlock> l(lock_);
+ std::lock_guard<rw_spinlock> l(lock_);
const string& uuid = instance.permanent_uuid();
if (!ContainsKey(servers_by_id_, uuid)) {
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/server/hybrid_clock.cc
----------------------------------------------------------------------
diff --git a/src/kudu/server/hybrid_clock.cc b/src/kudu/server/hybrid_clock.cc
index 937964f..cc3b611 100644
--- a/src/kudu/server/hybrid_clock.cc
+++ b/src/kudu/server/hybrid_clock.cc
@@ -15,11 +15,11 @@
// specific language governing permissions and limitations
// under the License.
+#include "kudu/server/hybrid_clock.h"
+
#include <algorithm>
-#include <boost/thread/locks.hpp>
#include <glog/logging.h>
-
-#include "kudu/server/hybrid_clock.h"
+#include <mutex>
#include "kudu/gutil/bind.h"
#include "kudu/gutil/strings/substitute.h"
@@ -189,7 +189,7 @@ Timestamp HybridClock::Now() {
Timestamp now;
uint64_t error;
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
NowWithError(&now, &error);
return now;
}
@@ -199,7 +199,7 @@ Timestamp HybridClock::NowLatest() {
uint64_t error;
{
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
NowWithError(&now, &error);
}
@@ -271,7 +271,7 @@ void HybridClock::NowWithError(Timestamp* timestamp, uint64_t* max_error_usec) {
}
Status HybridClock::Update(const Timestamp& to_update) {
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
Timestamp now;
uint64_t error_ignored;
NowWithError(&now, &error_ignored);
@@ -306,7 +306,7 @@ Status HybridClock::WaitUntilAfter(const Timestamp& then_latest,
Timestamp now;
uint64_t error;
{
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
NowWithError(&now, &error);
}
@@ -350,7 +350,7 @@ Status HybridClock::WaitUntilAfter(const Timestamp& then_latest,
Timestamp now;
uint64_t error;
{
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
NowWithError(&now, &error);
}
if (now.CompareTo(then) > 0) {
@@ -372,7 +372,7 @@ bool HybridClock::IsAfter(Timestamp t) {
Timestamp now;
{
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
now = Timestamp(std::max(next_timestamp_, now_usec << kBitsToShift));
}
return t.value() < now.value();
@@ -410,14 +410,14 @@ kudu::Status HybridClock::WalltimeWithError(uint64_t* now_usec, uint64_t* error_
void HybridClock::SetMockClockWallTimeForTests(uint64_t now_usec) {
CHECK(FLAGS_use_mock_wall_clock);
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
CHECK_GE(now_usec, mock_clock_time_usec_);
mock_clock_time_usec_ = now_usec;
}
void HybridClock::SetMockMaxClockErrorForTests(uint64_t max_error_usec) {
CHECK(FLAGS_use_mock_wall_clock);
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
mock_clock_max_error_usec_ = max_error_usec;
}
@@ -431,7 +431,7 @@ uint64_t HybridClock::ErrorForMetrics() {
Timestamp now;
uint64_t error;
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
NowWithError(&now, &error);
return error;
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/server/webserver.cc
----------------------------------------------------------------------
diff --git a/src/kudu/server/webserver.cc b/src/kudu/server/webserver.cc
index 539bed5..d685bc6 100644
--- a/src/kudu/server/webserver.cc
+++ b/src/kudu/server/webserver.cc
@@ -17,18 +17,20 @@
#include "kudu/server/webserver.h"
#include <algorithm>
-#include <stdio.h>
-#include <signal.h>
-#include <string>
-#include <map>
-#include <vector>
-#include <boost/lexical_cast.hpp>
+#include <boost/algorithm/string.hpp>
#include <boost/bind.hpp>
+#include <boost/lexical_cast.hpp>
#include <boost/mem_fn.hpp>
-#include <boost/algorithm/string.hpp>
+#include <boost/thread/shared_mutex.hpp>
#include <gflags/gflags.h>
#include <glog/logging.h>
+#include <map>
+#include <mutex>
+#include <signal.h>
#include <squeasel.h>
+#include <stdio.h>
+#include <string>
+#include <vector>
#include "kudu/gutil/map-util.h"
#include "kudu/gutil/stl_util.h"
@@ -365,7 +367,7 @@ int Webserver::RunPathHandler(const PathHandler& handler,
void Webserver::RegisterPathHandler(const string& path, const string& alias,
const PathHandlerCallback& callback, bool is_styled, bool is_on_nav_bar) {
- boost::lock_guard<boost::shared_mutex> lock(lock_);
+ std::lock_guard<boost::shared_mutex> lock(lock_);
auto it = path_handlers_.find(path);
if (it == path_handlers_.end()) {
it = path_handlers_.insert(
@@ -423,7 +425,7 @@ bool Webserver::static_pages_available() const {
}
void Webserver::set_footer_html(const std::string& html) {
- boost::lock_guard<boost::shared_mutex> l(lock_);
+ std::lock_guard<boost::shared_mutex> l(lock_);
footer_html_ = html;
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/server/webserver.h
----------------------------------------------------------------------
diff --git a/src/kudu/server/webserver.h b/src/kudu/server/webserver.h
index 72ce092..6f19f1a 100644
--- a/src/kudu/server/webserver.h
+++ b/src/kudu/server/webserver.h
@@ -17,11 +17,10 @@
#ifndef KUDU_UTIL_WEBSERVER_H
#define KUDU_UTIL_WEBSERVER_H
+#include <boost/thread/shared_mutex.hpp>
#include <map>
#include <string>
#include <vector>
-#include <boost/function.hpp>
-#include <boost/thread/shared_mutex.hpp>
#include "kudu/server/webserver_options.h"
#include "kudu/util/net/sockaddr.h"
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/tablet/compaction.h
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/compaction.h b/src/kudu/tablet/compaction.h
index 04b55b0..9258ea0 100644
--- a/src/kudu/tablet/compaction.h
+++ b/src/kudu/tablet/compaction.h
@@ -18,6 +18,7 @@
#define KUDU_TABLET_COMPACTION_H
#include <memory>
+#include <mutex>
#include <string>
#include <vector>
@@ -78,10 +79,10 @@ class CompactionInput {
class RowSetsInCompaction {
public:
void AddRowSet(const std::shared_ptr<RowSet> &rowset,
- const std::shared_ptr<boost::mutex::scoped_try_lock> &lock) {
- CHECK(lock->owns_lock());
+ std::unique_lock<std::mutex> lock) {
+ CHECK(lock.owns_lock());
- locks_.push_back(lock);
+ locks_.push_back(std::move(lock));
rowsets_.push_back(rowset);
}
@@ -104,10 +105,8 @@ class RowSetsInCompaction {
}
private:
- typedef vector<std::shared_ptr<boost::mutex::scoped_try_lock> > LockVector;
-
RowSetVector rowsets_;
- LockVector locks_;
+ vector<std::unique_lock<std::mutex>> locks_;
};
// One row yielded by CompactionInput::PrepareBlock.
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/tablet/diskrowset.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/diskrowset.cc b/src/kudu/tablet/diskrowset.cc
index 549cfab..d00f601 100644
--- a/src/kudu/tablet/diskrowset.cc
+++ b/src/kudu/tablet/diskrowset.cc
@@ -16,8 +16,9 @@
// under the License.
#include <algorithm>
-#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
#include <glog/logging.h>
+#include <mutex>
#include <vector>
#include "kudu/common/generic_iterators.h"
@@ -520,7 +521,7 @@ Status DiskRowSet::MajorCompactDeltaStores() {
Status DiskRowSet::MajorCompactDeltaStoresWithColumnIds(const vector<ColumnId>& col_ids) {
TRACE_EVENT0("tablet", "DiskRowSet::MajorCompactDeltaStores");
- boost::lock_guard<Mutex> l(*delta_tracker()->compact_flush_lock());
+ std::lock_guard<Mutex> l(*delta_tracker()->compact_flush_lock());
// TODO: do we need to lock schema or anything here?
gscoped_ptr<MajorDeltaCompaction> compaction;
@@ -539,7 +540,7 @@ Status DiskRowSet::MajorCompactDeltaStoresWithColumnIds(const vector<ColumnId>&
gscoped_ptr<CFileSet> new_base(new CFileSet(rowset_metadata_));
RETURN_NOT_OK(new_base->Open());
{
- boost::lock_guard<percpu_rwlock> lock(component_lock_);
+ std::lock_guard<percpu_rwlock> lock(component_lock_);
RETURN_NOT_OK(compaction->UpdateDeltaTracker(delta_tracker_.get()));
base_data_.reset(new_base.release());
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/tablet/diskrowset.h
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/diskrowset.h b/src/kudu/tablet/diskrowset.h
index f82eb11..d638336 100644
--- a/src/kudu/tablet/diskrowset.h
+++ b/src/kudu/tablet/diskrowset.h
@@ -22,9 +22,9 @@
#ifndef KUDU_TABLET_DISKROWSET_H_
#define KUDU_TABLET_DISKROWSET_H_
-#include <boost/thread/mutex.hpp>
#include <gtest/gtest_prod.h>
#include <memory>
+#include <mutex>
#include <string>
#include <vector>
@@ -348,7 +348,7 @@ class DiskRowSet : public RowSet {
// Major compacts all the delta files for all the columns.
Status MajorCompactDeltaStores();
- boost::mutex *compact_flush_lock() OVERRIDE {
+ std::mutex *compact_flush_lock() OVERRIDE {
return &compact_flush_lock_;
}
@@ -402,7 +402,7 @@ class DiskRowSet : public RowSet {
// Lock governing this rowset's inclusion in a compact/flush. If locked,
// no other compactor will attempt to include this rowset.
- boost::mutex compact_flush_lock_;
+ std::mutex compact_flush_lock_;
DISALLOW_COPY_AND_ASSIGN(DiskRowSet);
};
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/tablet/lock_manager-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/lock_manager-test.cc b/src/kudu/tablet/lock_manager-test.cc
index ea0edf7..eccb67b 100644
--- a/src/kudu/tablet/lock_manager-test.cc
+++ b/src/kudu/tablet/lock_manager-test.cc
@@ -16,11 +16,10 @@
// under the License.
#include <algorithm>
-#include <boost/thread/locks.hpp>
-#include <boost/thread/mutex.hpp>
#include <glog/logging.h>
#include <gtest/gtest.h>
#include <memory>
+#include <mutex>
#include <vector>
#include "kudu/gutil/gscoped_ptr.h"
@@ -118,7 +117,7 @@ class LmTestResource {
}
void acquire(uint64_t tid) {
- boost::unique_lock<boost::mutex> lock(lock_);
+ std::unique_lock<std::mutex> lock(lock_);
CHECK(!is_owned_);
CHECK_EQ(0, owner_);
owner_ = tid;
@@ -126,7 +125,7 @@ class LmTestResource {
}
void release(uint64_t tid) {
- boost::unique_lock<boost::mutex> lock(lock_);
+ std::unique_lock<std::mutex> lock(lock_);
CHECK(is_owned_);
CHECK_EQ(tid, owner_);
owner_ = 0;
@@ -137,7 +136,7 @@ class LmTestResource {
DISALLOW_COPY_AND_ASSIGN(LmTestResource);
const Slice* id_;
- boost::mutex lock_;
+ std::mutex lock_;
uint64_t owner_;
bool is_owned_;
};
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/tablet/lock_manager.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/lock_manager.cc b/src/kudu/tablet/lock_manager.cc
index b0d657e..af48540 100644
--- a/src/kudu/tablet/lock_manager.cc
+++ b/src/kudu/tablet/lock_manager.cc
@@ -15,17 +15,18 @@
// specific language governing permissions and limitations
// under the License.
-#include <boost/thread/locks.hpp>
-#include <boost/thread/mutex.hpp>
+#include "kudu/tablet/lock_manager.h"
+
+#include <boost/thread/shared_mutex.hpp>
#include <glog/logging.h>
-#include <string>
+#include <mutex>
#include <semaphore.h>
+#include <string>
#include "kudu/gutil/dynamic_annotations.h"
#include "kudu/gutil/gscoped_ptr.h"
#include "kudu/gutil/hash/city.h"
#include "kudu/gutil/walltime.h"
-#include "kudu/tablet/lock_manager.h"
#include "kudu/util/locks.h"
#include "kudu/util/semaphore.h"
#include "kudu/util/trace.h"
@@ -169,7 +170,7 @@ LockEntry *LockTable::GetLockEntry(const Slice& key) {
boost::shared_lock<rw_spinlock> table_rdlock(lock_.get_lock());
Bucket *bucket = FindBucket(new_entry->key_hash_);
{
- boost::lock_guard<simple_spinlock> bucket_lock(bucket->lock);
+ std::lock_guard<simple_spinlock> bucket_lock(bucket->lock);
LockEntry **node = FindSlot(bucket, new_entry->key_, new_entry->key_hash_);
old_entry = *node;
if (old_entry != nullptr) {
@@ -188,7 +189,7 @@ LockEntry *LockTable::GetLockEntry(const Slice& key) {
}
if (base::subtle::NoBarrier_AtomicIncrement(&item_count_, 1) > size_) {
- boost::unique_lock<percpu_rwlock> table_wrlock(lock_, boost::try_to_lock);
+ std::unique_lock<percpu_rwlock> table_wrlock(lock_, std::try_to_lock);
// if we can't take the lock, means that someone else is resizing.
// (The percpu_rwlock try_lock waits for readers to complete)
if (table_wrlock.owns_lock()) {
@@ -202,10 +203,10 @@ LockEntry *LockTable::GetLockEntry(const Slice& key) {
void LockTable::ReleaseLockEntry(LockEntry *entry) {
bool removed = false;
{
- boost::lock_guard<rw_spinlock> table_rdlock(lock_.get_lock());
+ std::lock_guard<rw_spinlock> table_rdlock(lock_.get_lock());
Bucket *bucket = FindBucket(entry->key_hash_);
{
- boost::lock_guard<simple_spinlock> bucket_lock(bucket->lock);
+ std::lock_guard<simple_spinlock> bucket_lock(bucket->lock);
LockEntry **node = FindEntry(bucket, entry);
if (node != nullptr) {
// ASSUMPTION: There are few updates, so locking the same row at the same time is rare
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/tablet/memrowset.h
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/memrowset.h b/src/kudu/tablet/memrowset.h
index 962a0e1..364e3df 100644
--- a/src/kudu/tablet/memrowset.h
+++ b/src/kudu/tablet/memrowset.h
@@ -17,8 +17,9 @@
#ifndef KUDU_TABLET_MEMROWSET_H
#define KUDU_TABLET_MEMROWSET_H
-#include <boost/optional.hpp>
+#include <boost/optional/optional_fwd.hpp>
#include <memory>
+#include <mutex>
#include <string>
#include <vector>
@@ -227,7 +228,7 @@ class MemRowSet : public RowSet,
return 0;
}
- boost::mutex *compact_flush_lock() OVERRIDE {
+ std::mutex *compact_flush_lock() OVERRIDE {
return &compact_flush_lock_;
}
@@ -360,7 +361,7 @@ class MemRowSet : public RowSet,
volatile uint64_t debug_insert_count_;
volatile uint64_t debug_update_count_;
- boost::mutex compact_flush_lock_;
+ std::mutex compact_flush_lock_;
Atomic32 has_logged_throttling_;
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/tablet/mock-rowsets.h
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/mock-rowsets.h b/src/kudu/tablet/mock-rowsets.h
index bccdf67..cc7f0f4 100644
--- a/src/kudu/tablet/mock-rowsets.h
+++ b/src/kudu/tablet/mock-rowsets.h
@@ -18,6 +18,7 @@
#define KUDU_TABLET_MOCK_ROWSETS_H
#include <memory>
+#include <mutex>
#include <string>
#include <vector>
@@ -77,7 +78,7 @@ class MockRowSet : public RowSet {
LOG(FATAL) << "Unimplemented";
return 0;
}
- virtual boost::mutex *compact_flush_lock() OVERRIDE {
+ virtual std::mutex *compact_flush_lock() OVERRIDE {
LOG(FATAL) << "Unimplemented";
return NULL;
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/cfa9a99f/src/kudu/tablet/mvcc-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/mvcc-test.cc b/src/kudu/tablet/mvcc-test.cc
index d54a10a..7e166c5 100644
--- a/src/kudu/tablet/mvcc-test.cc
+++ b/src/kudu/tablet/mvcc-test.cc
@@ -15,9 +15,9 @@
// specific language governing permissions and limitations
// under the License.
-#include <boost/thread/locks.hpp>
#include <glog/logging.h>
#include <gtest/gtest.h>
+#include <mutex>
#include <thread>
#include "kudu/server/hybrid_clock.h"
@@ -45,12 +45,12 @@ class MvccTest : public KuduTest {
MvccSnapshot s;
CHECK_OK(mgr->WaitForCleanSnapshotAtTimestamp(ts, &s, MonoTime::Max()));
CHECK(s.is_clean()) << "verifying postcondition";
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
result_snapshot_.reset(new MvccSnapshot(s));
}
bool HasResultSnapshot() {
- boost::lock_guard<simple_spinlock> lock(lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
return result_snapshot_ != nullptr;
}
[5/5] incubator-kudu git commit: Replace kudu::{lock_guard,
unique_lock} with std lib equivalents
Posted by da...@apache.org.
Replace kudu::{lock_guard, unique_lock} with std lib equivalents
Change-Id: I0f9e0f78fed9a35330c0324d1f3bc1c89f6ab47d
Reviewed-on: http://gerrit.cloudera.org:8080/3271
Reviewed-by: Mike Percy <mp...@apache.org>
Tested-by: Kudu Jenkins
Project: http://git-wip-us.apache.org/repos/asf/incubator-kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-kudu/commit/8a75ceee
Tree: http://git-wip-us.apache.org/repos/asf/incubator-kudu/tree/8a75ceee
Diff: http://git-wip-us.apache.org/repos/asf/incubator-kudu/diff/8a75ceee
Branch: refs/heads/master
Commit: 8a75ceeee5d17b387b10134197023694ccaf289a
Parents: cfa9a99
Author: Dan Burkert <da...@cloudera.com>
Authored: Wed Jun 1 10:59:58 2016 -0700
Committer: Dan Burkert <da...@cloudera.com>
Committed: Thu Jun 2 00:51:59 2016 +0000
----------------------------------------------------------------------
src/kudu/client/batcher.cc | 29 ++++----
src/kudu/client/client-internal.cc | 9 +--
src/kudu/client/client.cc | 7 +-
src/kudu/client/error_collector.cc | 7 +-
src/kudu/client/meta_cache.cc | 43 ++++++------
src/kudu/client/session-internal.cc | 6 +-
src/kudu/consensus/consensus-test-util.h | 12 ++--
src/kudu/consensus/consensus_queue.cc | 12 ++--
src/kudu/consensus/leader_election.cc | 11 +--
src/kudu/consensus/log_cache.cc | 23 ++++---
src/kudu/consensus/log_index.cc | 11 +--
src/kudu/consensus/raft_consensus_state.cc | 36 +++++-----
src/kudu/consensus/raft_consensus_state.h | 3 +-
src/kudu/fs/block_manager-stress-test.cc | 5 +-
src/kudu/fs/file_block_manager.cc | 6 +-
src/kudu/fs/log_block_manager.cc | 38 ++++++-----
src/kudu/master/master_rpc.cc | 7 +-
src/kudu/master/ts_descriptor.cc | 2 +-
src/kudu/master/ts_descriptor.h | 5 +-
src/kudu/rpc/messenger.cc | 15 +++--
src/kudu/rpc/outbound_call.cc | 19 +++---
src/kudu/rpc/reactor.cc | 15 ++---
src/kudu/rpc/request_tracker.cc | 9 ++-
src/kudu/rpc/rpc_controller.cc | 10 +--
src/kudu/rpc/rpcz_store.cc | 2 +-
src/kudu/rpc/service_queue.cc | 15 +++--
src/kudu/tablet/delta_tracker.cc | 15 +++--
src/kudu/tablet/maintenance_manager-test.cc | 19 +++---
src/kudu/tablet/maintenance_manager.cc | 12 ++--
src/kudu/tablet/mvcc.h | 3 +-
src/kudu/tablet/rowset_metadata.cc | 13 ++--
src/kudu/tablet/rowset_metadata.h | 27 ++++----
src/kudu/tablet/tablet_peer.cc | 8 +--
src/kudu/tablet/transactions/transaction.h | 7 +-
.../tablet/transactions/transaction_tracker.cc | 10 +--
.../tablet/transactions/write_transaction.cc | 4 +-
.../tablet/transactions/write_transaction.h | 7 +-
src/kudu/tools/ksck.cc | 5 +-
src/kudu/util/cache.cc | 9 +--
src/kudu/util/failure_detector.cc | 21 +++---
src/kudu/util/locks.h | 71 +-------------------
src/kudu/util/mem_tracker.cc | 3 +-
src/kudu/util/memory/arena.cc | 8 +--
src/kudu/util/memory/arena.h | 6 +-
src/kudu/util/metrics.cc | 28 ++++----
src/kudu/util/metrics.h | 17 ++---
src/kudu/util/nvm_cache.cc | 11 +--
src/kudu/util/path_util.cc | 6 +-
src/kudu/util/random.h | 23 ++++---
src/kudu/util/resettable_heartbeater.cc | 9 +--
src/kudu/util/test_graph.cc | 10 +--
src/kudu/util/trace.cc | 9 +--
src/kudu/util/trace_metrics.cc | 3 +-
src/kudu/util/trace_metrics.h | 5 +-
54 files changed, 354 insertions(+), 372 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/client/batcher.cc
----------------------------------------------------------------------
diff --git a/src/kudu/client/batcher.cc b/src/kudu/client/batcher.cc
index c544b3e..81add5a 100644
--- a/src/kudu/client/batcher.cc
+++ b/src/kudu/client/batcher.cc
@@ -21,6 +21,7 @@
#include <boost/bind.hpp>
#include <glog/logging.h>
#include <memory>
+#include <mutex>
#include <set>
#include <string>
#include <unordered_map>
@@ -393,12 +394,12 @@ Batcher::Batcher(KuduClient* client,
}
void Batcher::Abort() {
- unique_lock<simple_spinlock> l(&lock_);
+ std::unique_lock<simple_spinlock> l(lock_);
state_ = kAborted;
vector<InFlightOp*> to_abort;
for (InFlightOp* op : ops_) {
- lock_guard<simple_spinlock> l(&op->lock_);
+ std::lock_guard<simple_spinlock> l(op->lock_);
if (op->state == InFlightOp::kBufferedToTabletServer) {
to_abort.push_back(op);
}
@@ -428,18 +429,18 @@ Batcher::~Batcher() {
void Batcher::SetTimeoutMillis(int millis) {
CHECK_GE(millis, 0);
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
timeout_ = MonoDelta::FromMilliseconds(millis);
}
bool Batcher::HasPendingOperations() const {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
return !ops_.empty();
}
int Batcher::CountBufferedOperations() const {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
if (state_ == kGatheringOps) {
return ops_.size();
} else {
@@ -452,7 +453,7 @@ int Batcher::CountBufferedOperations() const {
void Batcher::CheckForFinishedFlush() {
sp::shared_ptr<KuduSession> session;
{
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
if (state_ != kFlushing || !ops_.empty()) {
return;
}
@@ -491,7 +492,7 @@ MonoTime Batcher::ComputeDeadlineUnlocked() const {
void Batcher::FlushAsync(KuduStatusCallback* cb) {
{
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
CHECK_EQ(state_, kGatheringOps);
state_ = kFlushing;
flush_callback_ = cb;
@@ -556,7 +557,7 @@ Status Batcher::Add(KuduWriteOperation* write_op) {
void Batcher::AddInFlightOp(InFlightOp* op) {
DCHECK_EQ(op->state, InFlightOp::kLookingUpTablet);
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
CHECK_EQ(state_, kGatheringOps);
InsertOrDie(&ops_, op);
op->sequence_number_ = next_op_sequence_number_++;
@@ -567,12 +568,12 @@ bool Batcher::IsAbortedUnlocked() const {
}
void Batcher::MarkHadErrors() {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
had_errors_ = true;
}
void Batcher::MarkInFlightOpFailed(InFlightOp* op, const Status& s) {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
MarkInFlightOpFailedUnlocked(op, s);
}
@@ -591,7 +592,7 @@ void Batcher::TabletLookupFinished(InFlightOp* op, const Status& s) {
// Acquire the batcher lock early to atomically:
// 1. Test if the batcher was aborted, and
// 2. Change the op state.
- unique_lock<simple_spinlock> l(&lock_);
+ std::unique_lock<simple_spinlock> l(lock_);
if (IsAbortedUnlocked()) {
VLOG(1) << "Aborted batch: TabletLookupFinished for " << op->write_op->ToString();
@@ -621,7 +622,7 @@ void Batcher::TabletLookupFinished(InFlightOp* op, const Status& s) {
}
{
- lock_guard<simple_spinlock> l2(&op->lock_);
+ std::lock_guard<simple_spinlock> l2(op->lock_);
CHECK_EQ(op->state, InFlightOp::kLookingUpTablet);
CHECK(op->tablet != NULL);
@@ -662,7 +663,7 @@ void Batcher::FlushBuffersIfReady() {
// 2. All outstanding ops have finished lookup. Why? To avoid a situation
// where ops are flushed one by one as they finish lookup.
{
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
if (state_ != kFlushing) {
VLOG(3) << "FlushBuffersIfReady: batcher not yet in flushing state";
return;
@@ -737,7 +738,7 @@ void Batcher::ProcessWriteResponse(const WriteRpc& rpc,
// Remove all the ops from the "in-flight" list.
{
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
for (InFlightOp* op : rpc.ops()) {
CHECK_EQ(1, ops_.erase(op))
<< "Could not remove op " << op->ToString()
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/client/client-internal.cc
----------------------------------------------------------------------
diff --git a/src/kudu/client/client-internal.cc b/src/kudu/client/client-internal.cc
index 4ed4a6c..f7f2420 100644
--- a/src/kudu/client/client-internal.cc
+++ b/src/kudu/client/client-internal.cc
@@ -19,6 +19,7 @@
#include <algorithm>
#include <limits>
+#include <mutex>
#include <string>
#include <vector>
@@ -757,7 +758,7 @@ void KuduClient::Data::LeaderMasterDetermined(const Status& status,
vector<StatusCallback> cbs;
{
- lock_guard<simple_spinlock> l(&leader_master_lock_);
+ std::lock_guard<simple_spinlock> l(leader_master_lock_);
cbs.swap(leader_master_callbacks_);
leader_master_rpc_.reset();
@@ -818,7 +819,7 @@ void KuduClient::Data::SetMasterServerProxyAsync(KuduClient* client,
// in parallel, since the requests should end up with the same result.
// Instead, we simply piggy-back onto the existing request by adding our own
// callback to leader_master_callbacks_.
- unique_lock<simple_spinlock> l(&leader_master_lock_);
+ std::unique_lock<simple_spinlock> l(leader_master_lock_);
leader_master_callbacks_.push_back(cb);
if (!leader_master_rpc_) {
// No one is sending a request yet - we need to be the one to do it.
@@ -836,12 +837,12 @@ void KuduClient::Data::SetMasterServerProxyAsync(KuduClient* client,
}
HostPort KuduClient::Data::leader_master_hostport() const {
- lock_guard<simple_spinlock> l(&leader_master_lock_);
+ std::lock_guard<simple_spinlock> l(leader_master_lock_);
return leader_master_hostport_;
}
shared_ptr<master::MasterServiceProxy> KuduClient::Data::master_proxy() const {
- lock_guard<simple_spinlock> l(&leader_master_lock_);
+ std::lock_guard<simple_spinlock> l(leader_master_lock_);
return master_proxy_;
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/client/client.cc
----------------------------------------------------------------------
diff --git a/src/kudu/client/client.cc b/src/kudu/client/client.cc
index a58a772..5b6d900 100644
--- a/src/kudu/client/client.cc
+++ b/src/kudu/client/client.cc
@@ -19,6 +19,7 @@
#include <algorithm>
#include <boost/bind.hpp>
+#include <mutex>
#include <set>
#include <string>
#include <unordered_map>
@@ -714,7 +715,7 @@ void KuduSession::FlushAsync(KuduStatusCallback* user_callback) {
// Save off the old batcher.
scoped_refptr<Batcher> old_batcher;
{
- lock_guard<simple_spinlock> l(&data_->lock_);
+ std::lock_guard<simple_spinlock> l(data_->lock_);
data_->NewBatcher(shared_from_this(), &old_batcher);
InsertOrDie(&data_->flushed_batchers_, old_batcher.get());
}
@@ -726,7 +727,7 @@ void KuduSession::FlushAsync(KuduStatusCallback* user_callback) {
}
bool KuduSession::HasPendingOperations() const {
- lock_guard<simple_spinlock> l(&data_->lock_);
+ std::lock_guard<simple_spinlock> l(data_->lock_);
if (data_->batcher_->HasPendingOperations()) {
return true;
}
@@ -761,7 +762,7 @@ Status KuduSession::Apply(KuduWriteOperation* write_op) {
}
int KuduSession::CountBufferedOperations() const {
- lock_guard<simple_spinlock> l(&data_->lock_);
+ std::lock_guard<simple_spinlock> l(data_->lock_);
CHECK_EQ(data_->flush_mode_, MANUAL_FLUSH);
return data_->batcher_->CountBufferedOperations();
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/client/error_collector.cc
----------------------------------------------------------------------
diff --git a/src/kudu/client/error_collector.cc b/src/kudu/client/error_collector.cc
index 987372f..84023d6 100644
--- a/src/kudu/client/error_collector.cc
+++ b/src/kudu/client/error_collector.cc
@@ -18,6 +18,7 @@
#include "kudu/client/client.h"
#include "kudu/client/error_collector.h"
+#include <mutex>
#include <vector>
#include "kudu/gutil/stl_util.h"
@@ -34,17 +35,17 @@ ErrorCollector::~ErrorCollector() {
}
void ErrorCollector::AddError(gscoped_ptr<KuduError> error) {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
errors_.push_back(error.release());
}
int ErrorCollector::CountErrors() const {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
return errors_.size();
}
void ErrorCollector::GetErrors(std::vector<KuduError*>* errors, bool* overflowed) {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
errors->swap(errors_);
*overflowed = false;
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/client/meta_cache.cc
----------------------------------------------------------------------
diff --git a/src/kudu/client/meta_cache.cc b/src/kudu/client/meta_cache.cc
index 18cb0a7..fa4142b 100644
--- a/src/kudu/client/meta_cache.cc
+++ b/src/kudu/client/meta_cache.cc
@@ -19,6 +19,7 @@
#include <boost/bind.hpp>
#include <glog/logging.h>
+#include <mutex>
#include "kudu/client/client.h"
#include "kudu/client/client-internal.h"
@@ -89,7 +90,7 @@ void RemoteTabletServer::DnsResolutionFinished(const HostPort& hp,
<< (*addrs)[0].ToString();
{
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
proxy_.reset(new TabletServerServiceProxy(client->data_->messenger_, (*addrs)[0]));
}
user_callback.Run(s);
@@ -98,7 +99,7 @@ void RemoteTabletServer::DnsResolutionFinished(const HostPort& hp,
void RemoteTabletServer::InitProxy(KuduClient* client, const StatusCallback& cb) {
HostPort hp;
{
- unique_lock<simple_spinlock> l(&lock_);
+ std::unique_lock<simple_spinlock> l(lock_);
if (proxy_) {
// Already have a proxy created.
@@ -122,7 +123,7 @@ void RemoteTabletServer::InitProxy(KuduClient* client, const StatusCallback& cb)
void RemoteTabletServer::Update(const master::TSInfoPB& pb) {
CHECK_EQ(pb.permanent_uuid(), uuid_);
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
rpc_hostports_.clear();
for (const HostPortPB& hostport_pb : pb.rpc_addresses()) {
@@ -135,14 +136,14 @@ string RemoteTabletServer::permanent_uuid() const {
}
shared_ptr<TabletServerServiceProxy> RemoteTabletServer::proxy() const {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
CHECK(proxy_);
return proxy_;
}
string RemoteTabletServer::ToString() const {
string ret = uuid_;
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
if (!rpc_hostports_.empty()) {
strings::SubstituteAndAppend(&ret, " ($0)", rpc_hostports_[0].ToString());
}
@@ -150,7 +151,7 @@ string RemoteTabletServer::ToString() const {
}
void RemoteTabletServer::GetHostPorts(vector<HostPort>* host_ports) const {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
*host_ports = rpc_hostports_;
}
@@ -161,7 +162,7 @@ void RemoteTablet::Refresh(const TabletServerMap& tservers,
const google::protobuf::RepeatedPtrField
<TabletLocationsPB_ReplicaPB>& replicas) {
// Adopt the data from the successful response.
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
replicas_.clear();
for (const TabletLocationsPB_ReplicaPB& r : replicas) {
RemoteReplica rep;
@@ -174,19 +175,19 @@ void RemoteTablet::Refresh(const TabletServerMap& tservers,
}
void RemoteTablet::MarkStale() {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
stale_ = true;
}
bool RemoteTablet::stale() const {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
return stale_;
}
bool RemoteTablet::MarkReplicaFailed(RemoteTabletServer *ts,
const Status& status) {
bool found = false;
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
VLOG(2) << "Tablet " << tablet_id_ << ": Current remote replicas in meta cache: "
<< ReplicasAsStringUnlocked();
LOG(WARNING) << "Tablet " << tablet_id_ << ": Replica " << ts->ToString()
@@ -202,7 +203,7 @@ bool RemoteTablet::MarkReplicaFailed(RemoteTabletServer *ts,
int RemoteTablet::GetNumFailedReplicas() const {
int failed = 0;
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
for (const RemoteReplica& rep : replicas_) {
if (rep.failed) {
failed++;
@@ -212,7 +213,7 @@ int RemoteTablet::GetNumFailedReplicas() const {
}
RemoteTabletServer* RemoteTablet::LeaderTServer() const {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
for (const RemoteReplica& replica : replicas_) {
if (!replica.failed && replica.role == RaftPeerPB::LEADER) {
return replica.ts;
@@ -226,7 +227,7 @@ bool RemoteTablet::HasLeader() const {
}
void RemoteTablet::GetRemoteTabletServers(vector<RemoteTabletServer*>* servers) const {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
for (const RemoteReplica& replica : replicas_) {
if (replica.failed) {
continue;
@@ -237,7 +238,7 @@ void RemoteTablet::GetRemoteTabletServers(vector<RemoteTabletServer*>* servers)
void RemoteTablet::MarkTServerAsLeader(const RemoteTabletServer* server) {
bool found = false;
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
for (RemoteReplica& replica : replicas_) {
if (replica.ts == server) {
replica.role = RaftPeerPB::LEADER;
@@ -253,7 +254,7 @@ void RemoteTablet::MarkTServerAsLeader(const RemoteTabletServer* server) {
void RemoteTablet::MarkTServerAsFollower(const RemoteTabletServer* server) {
bool found = false;
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
for (RemoteReplica& replica : replicas_) {
if (replica.ts == server) {
replica.role = RaftPeerPB::FOLLOWER;
@@ -266,7 +267,7 @@ void RemoteTablet::MarkTServerAsFollower(const RemoteTabletServer* server) {
}
std::string RemoteTablet::ReplicasAsString() const {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
return ReplicasAsStringUnlocked();
}
@@ -319,7 +320,7 @@ void MetaCacheServerPicker::PickLeader(const ServerPickedCallback& callback,
leader = tablet_->LeaderTServer();
bool marked_as_follower = false;
{
- lock_guard<simple_spinlock> lock(&lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
marked_as_follower = ContainsKey(followers_, leader);
}
@@ -341,7 +342,7 @@ void MetaCacheServerPicker::PickLeader(const ServerPickedCallback& callback,
tablet_->GetRemoteTabletServers(&replicas);
set<RemoteTabletServer*> followers_copy;
{
- lock_guard<simple_spinlock> lock(&lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
followers_copy = followers_;
}
@@ -398,7 +399,7 @@ void MetaCacheServerPicker::MarkServerFailed(RemoteTabletServer* replica, const
void MetaCacheServerPicker::MarkReplicaNotLeader(RemoteTabletServer* replica) {
{
- lock_guard<simple_spinlock> lock(&lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
followers_.insert(replica);
}
}
@@ -413,7 +414,7 @@ void MetaCacheServerPicker::LookUpTabletCb(const ServerPickedCallback& callback,
const Status& status) {
// Whenever we lookup the tablet, clear the set of followers.
{
- lock_guard<simple_spinlock> lock(&lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
followers_.clear();
}
@@ -707,7 +708,7 @@ const scoped_refptr<RemoteTablet>& MetaCache::ProcessLookupResponse(const Lookup
VLOG(2) << "Processing master response for " << rpc.ToString()
<< ". Response: " << rpc.resp().ShortDebugString();
- lock_guard<rw_spinlock> l(&lock_);
+ std::lock_guard<rw_spinlock> l(lock_);
TabletMap& tablets_by_key = LookupOrInsert(&tablets_by_table_and_key_,
rpc.table_id(), TabletMap());
for (const TabletLocationsPB& loc : rpc.resp().tablet_locations()) {
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/client/session-internal.cc
----------------------------------------------------------------------
diff --git a/src/kudu/client/session-internal.cc b/src/kudu/client/session-internal.cc
index 062615f..552b507 100644
--- a/src/kudu/client/session-internal.cc
+++ b/src/kudu/client/session-internal.cc
@@ -17,6 +17,8 @@
#include "kudu/client/session-internal.h"
+#include <mutex>
+
#include "kudu/client/batcher.h"
#include "kudu/client/error_collector.h"
#include "kudu/client/shared_ptr.h"
@@ -42,7 +44,7 @@ KuduSession::Data::~Data() {
}
void KuduSession::Data::Init(const shared_ptr<KuduSession>& session) {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
CHECK(!batcher_);
NewBatcher(session, NULL);
}
@@ -65,7 +67,7 @@ void KuduSession::Data::NewBatcher(const shared_ptr<KuduSession>& session,
}
void KuduSession::Data::FlushFinished(Batcher* batcher) {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
CHECK_EQ(flushed_batchers_.erase(batcher), 1);
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/consensus/consensus-test-util.h
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/consensus-test-util.h b/src/kudu/consensus/consensus-test-util.h
index 4d50bd9..b600c36 100644
--- a/src/kudu/consensus/consensus-test-util.h
+++ b/src/kudu/consensus/consensus-test-util.h
@@ -174,14 +174,14 @@ class DelayablePeerProxy : public TestPeerProxy {
// Delay the answer to the next response to this remote
// peer. The response callback will only be called on Respond().
virtual void DelayResponse() {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
delay_response_ = true;
latch_.Reset(1); // Reset for the next time.
}
virtual void RespondUnlessDelayed(Method method) {
{
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
if (delay_response_) {
latch_.CountDown();
delay_response_ = false;
@@ -238,14 +238,14 @@ class MockedPeerProxy : public TestPeerProxy {
virtual void set_update_response(const ConsensusResponsePB& update_response) {
CHECK(update_response.IsInitialized()) << update_response.ShortDebugString();
{
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
update_response_ = update_response;
}
}
virtual void set_vote_response(const VoteResponsePB& vote_response) {
{
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
vote_response_ = vote_response;
}
}
@@ -255,7 +255,7 @@ class MockedPeerProxy : public TestPeerProxy {
rpc::RpcController* controller,
const rpc::ResponseCallback& callback) OVERRIDE {
{
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
update_count_++;
*response = update_response_;
}
@@ -272,7 +272,7 @@ class MockedPeerProxy : public TestPeerProxy {
// Return the number of times that UpdateAsync() has been called.
int update_count() const {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
return update_count_;
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/consensus/consensus_queue.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/consensus_queue.cc b/src/kudu/consensus/consensus_queue.cc
index 0a8f478..c622c01 100644
--- a/src/kudu/consensus/consensus_queue.cc
+++ b/src/kudu/consensus/consensus_queue.cc
@@ -229,7 +229,7 @@ void PeerMessageQueue::LocalPeerAppendFinished(const OpId& id,
*fake_response.mutable_status()->mutable_last_received() = id;
*fake_response.mutable_status()->mutable_last_received_current_leader() = id;
{
- std::unique_lock<simple_spinlock> lock(queue_lock_);
+ std::lock_guard<simple_spinlock> lock(queue_lock_);
fake_response.mutable_status()->set_last_committed_idx(queue_state_.committed_index.index());
}
bool junk;
@@ -278,7 +278,7 @@ Status PeerMessageQueue::RequestForPeer(const string& uuid,
TrackedPeer* peer = nullptr;
OpId preceding_id;
{
- lock_guard<simple_spinlock> lock(&queue_lock_);
+ std::lock_guard<simple_spinlock> lock(queue_lock_);
DCHECK_EQ(queue_state_.state, kQueueOpen);
DCHECK_NE(uuid, local_peer_pb_.permanent_uuid());
@@ -390,7 +390,7 @@ Status PeerMessageQueue::GetRemoteBootstrapRequestForPeer(const string& uuid,
StartRemoteBootstrapRequestPB* req) {
TrackedPeer* peer = nullptr;
{
- lock_guard<simple_spinlock> lock(&queue_lock_);
+ std::lock_guard<simple_spinlock> lock(queue_lock_);
DCHECK_EQ(queue_state_.state, kQueueOpen);
DCHECK_NE(uuid, local_peer_pb_.permanent_uuid());
peer = FindPtrOrNull(peers_map_, uuid);
@@ -466,7 +466,7 @@ void PeerMessageQueue::AdvanceQueueWatermark(const char* type,
}
void PeerMessageQueue::NotifyPeerIsResponsiveDespiteError(const std::string& peer_uuid) {
- lock_guard<simple_spinlock> l(&queue_lock_);
+ std::lock_guard<simple_spinlock> l(queue_lock_);
TrackedPeer* peer = FindPtrOrNull(peers_map_, peer_uuid);
if (!peer) return;
peer->last_successful_communication_time = MonoTime::Now(MonoTime::FINE);
@@ -481,7 +481,7 @@ void PeerMessageQueue::ResponseFromPeer(const std::string& peer_uuid,
OpId updated_majority_replicated_opid;
Mode mode_copy;
{
- unique_lock<simple_spinlock> scoped_lock(&queue_lock_);
+ std::lock_guard<simple_spinlock> scoped_lock(queue_lock_);
DCHECK_NE(kQueueConstructed, queue_state_.state);
TrackedPeer* peer = FindPtrOrNull(peers_map_, peer_uuid);
@@ -646,7 +646,7 @@ void PeerMessageQueue::ResponseFromPeer(const std::string& peer_uuid,
}
PeerMessageQueue::TrackedPeer PeerMessageQueue::GetTrackedPeerForTests(string uuid) {
- unique_lock<simple_spinlock> scoped_lock(&queue_lock_);
+ std::lock_guard<simple_spinlock> scoped_lock(queue_lock_);
TrackedPeer* tracked = FindOrDie(peers_map_, uuid);
return *tracked;
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/consensus/leader_election.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/leader_election.cc b/src/kudu/consensus/leader_election.cc
index 0133c04..92723d0 100644
--- a/src/kudu/consensus/leader_election.cc
+++ b/src/kudu/consensus/leader_election.cc
@@ -18,6 +18,7 @@
#include "kudu/consensus/leader_election.h"
#include <boost/bind.hpp>
+#include <mutex>
#include "kudu/consensus/consensus_peers.h"
#include "kudu/consensus/metadata.pb.h"
@@ -182,7 +183,7 @@ LeaderElection::LeaderElection(const RaftConfigPB& config,
}
LeaderElection::~LeaderElection() {
- lock_guard<Lock> guard(&lock_);
+ std::lock_guard<Lock> guard(lock_);
DCHECK(has_responded_); // We must always call the callback exactly once.
STLDeleteValues(&voter_state_);
}
@@ -198,7 +199,7 @@ void LeaderElection::Run() {
for (const std::string& voter_uuid : follower_uuids_) {
VoterState* state = nullptr;
{
- lock_guard<Lock> guard(&lock_);
+ std::lock_guard<Lock> guard(lock_);
state = FindOrDie(voter_state_, voter_uuid);
// Safe to drop the lock because voter_state_ is not mutated outside of
// the constructor / destructor. We do this to avoid deadlocks below.
@@ -211,7 +212,7 @@ void LeaderElection::Run() {
<< voter_uuid << ": " << state->proxy_status.ToString()
<< ". Counting it as a 'NO' vote.";
{
- lock_guard<Lock> guard(&lock_);
+ std::lock_guard<Lock> guard(lock_);
RecordVoteUnlocked(voter_uuid, VOTE_DENIED);
}
CheckForDecision();
@@ -239,7 +240,7 @@ void LeaderElection::Run() {
void LeaderElection::CheckForDecision() {
bool to_respond = false;
{
- lock_guard<Lock> guard(&lock_);
+ std::lock_guard<Lock> guard(lock_);
// Check if the vote has been newly decided.
if (!result_ && vote_counter_->IsDecided()) {
ElectionVote decision;
@@ -266,7 +267,7 @@ void LeaderElection::CheckForDecision() {
void LeaderElection::VoteResponseRpcCallback(const std::string& voter_uuid) {
{
- lock_guard<Lock> guard(&lock_);
+ std::lock_guard<Lock> guard(lock_);
VoterState* state = FindOrDie(voter_state_, voter_uuid);
// Check for RPC errors.
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/consensus/log_cache.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/log_cache.cc b/src/kudu/consensus/log_cache.cc
index 605eae6..643cf29 100644
--- a/src/kudu/consensus/log_cache.cc
+++ b/src/kudu/consensus/log_cache.cc
@@ -22,6 +22,7 @@
#include <google/protobuf/wire_format_lite.h>
#include <google/protobuf/wire_format_lite_inl.h>
#include <map>
+#include <mutex>
#include <vector>
#include "kudu/consensus/log.h"
@@ -110,7 +111,7 @@ LogCache::~LogCache() {
}
void LogCache::Init(const OpId& preceding_op) {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
CHECK_EQ(cache_.size(), 1)
<< "Cache should have only our special '0' op";
next_sequential_op_index_ = preceding_op.index() + 1;
@@ -119,7 +120,7 @@ void LogCache::Init(const OpId& preceding_op) {
Status LogCache::AppendOperations(const vector<ReplicateRefPtr>& msgs,
const StatusCallback& callback) {
- unique_lock<simple_spinlock> l(&lock_);
+ std::unique_lock<simple_spinlock> l(lock_);
int size = msgs.size();
CHECK_GT(size, 0);
@@ -208,7 +209,7 @@ void LogCache::LogCallback(int64_t last_idx_in_batch,
const StatusCallback& user_callback,
const Status& log_status) {
if (log_status.ok()) {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
if (min_pinned_op_index_ <= last_idx_in_batch) {
VLOG_WITH_PREFIX_UNLOCKED(1) << "Updating pinned index to " << (last_idx_in_batch + 1);
min_pinned_op_index_ = last_idx_in_batch + 1;
@@ -227,14 +228,14 @@ void LogCache::LogCallback(int64_t last_idx_in_batch,
}
bool LogCache::HasOpBeenWritten(int64_t index) const {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
return index < next_sequential_op_index_;
}
Status LogCache::LookupOpId(int64_t op_index, OpId* op_id) const {
// First check the log cache itself.
{
- unique_lock<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
// We sometimes try to look up OpIds that have never been written
// on the local node. In that case, don't try to read the op from
@@ -275,7 +276,7 @@ Status LogCache::ReadOps(int64_t after_op_index,
DCHECK_GE(after_op_index, 0);
RETURN_NOT_OK(LookupOpId(after_op_index, preceding_op));
- unique_lock<simple_spinlock> l(&lock_);
+ std::unique_lock<simple_spinlock> l(lock_);
int64_t next_index = after_op_index + 1;
// Return as many operations as we can, up to the limit
@@ -342,7 +343,7 @@ Status LogCache::ReadOps(int64_t after_op_index,
void LogCache::EvictThroughOp(int64_t index) {
- lock_guard<simple_spinlock> lock(&lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
EvictSomeUnlocked(index, MathLimits<int64_t>::kMax);
}
@@ -399,7 +400,7 @@ int64_t LogCache::BytesUsed() const {
}
string LogCache::StatsString() const {
- lock_guard<simple_spinlock> lock(&lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
return StatsStringUnlocked();
}
@@ -410,7 +411,7 @@ string LogCache::StatsStringUnlocked() const {
}
std::string LogCache::ToString() const {
- lock_guard<simple_spinlock> lock(&lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
return ToStringUnlocked();
}
@@ -435,7 +436,7 @@ void LogCache::DumpToLog() const {
}
void LogCache::DumpToStrings(vector<string>* lines) const {
- lock_guard<simple_spinlock> lock(&lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
int counter = 0;
lines->push_back(ToStringUnlocked());
lines->push_back("Messages:");
@@ -452,7 +453,7 @@ void LogCache::DumpToStrings(vector<string>* lines) const {
void LogCache::DumpToHtml(std::ostream& out) const {
using std::endl;
- lock_guard<simple_spinlock> lock(&lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
out << "<h3>Messages:</h3>" << endl;
out << "<table>" << endl;
out << "<tr><th>Entry</th><th>OpId</th><th>Type</th><th>Size</th><th>Status</th></tr>" << endl;
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/consensus/log_index.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/log_index.cc b/src/kudu/consensus/log_index.cc
index 51ac6bd..8533b5c 100644
--- a/src/kudu/consensus/log_index.cc
+++ b/src/kudu/consensus/log_index.cc
@@ -29,10 +29,11 @@
#include "kudu/consensus/log_index.h"
#include <fcntl.h>
+#include <mutex>
#include <string>
#include <sys/mman.h>
-#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/types.h>
#include <unistd.h>
#include <vector>
@@ -170,7 +171,7 @@ Status LogIndex::GetChunkForIndex(int64_t log_index, bool create,
int64_t chunk_idx = log_index / kEntriesPerIndexChunk;
{
- lock_guard<simple_spinlock> l(&open_chunks_lock_);
+ std::lock_guard<simple_spinlock> l(open_chunks_lock_);
if (FindCopy(open_chunks_, chunk_idx, chunk)) {
return Status::OK();
}
@@ -183,7 +184,7 @@ Status LogIndex::GetChunkForIndex(int64_t log_index, bool create,
RETURN_NOT_OK_PREPEND(OpenChunk(chunk_idx, chunk),
"Couldn't open index chunk");
{
- lock_guard<simple_spinlock> l(&open_chunks_lock_);
+ std::lock_guard<simple_spinlock> l(open_chunks_lock_);
if (PREDICT_FALSE(ContainsKey(open_chunks_, chunk_idx))) {
// Someone else opened the chunk in the meantime.
// We'll just return that one.
@@ -241,7 +242,7 @@ void LogIndex::GC(int64_t min_index_to_retain) {
// Enumerate which chunks to delete.
vector<int64_t> chunks_to_delete;
{
- lock_guard<simple_spinlock> l(&open_chunks_lock_);
+ std::lock_guard<simple_spinlock> l(open_chunks_lock_);
for (auto it = open_chunks_.begin();
it != open_chunks_.lower_bound(min_chunk_to_retain); ++it) {
chunks_to_delete.push_back(it->first);
@@ -258,7 +259,7 @@ void LogIndex::GC(int64_t min_index_to_retain) {
}
LOG(INFO) << "Deleted log index segment " << path;
{
- lock_guard<simple_spinlock> l(&open_chunks_lock_);
+ std::lock_guard<simple_spinlock> l(open_chunks_lock_);
open_chunks_.erase(chunk_idx);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/consensus/raft_consensus_state.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/raft_consensus_state.cc b/src/kudu/consensus/raft_consensus_state.cc
index 4a70efb..dde6b61 100644
--- a/src/kudu/consensus/raft_consensus_state.cc
+++ b/src/kudu/consensus/raft_consensus_state.cc
@@ -78,48 +78,48 @@ Status ReplicaState::StartUnlocked(const OpId& last_id_in_wal) {
Status ReplicaState::LockForStart(UniqueLock* lock) const {
ThreadRestrictions::AssertWaitAllowed();
- UniqueLock l(&update_lock_);
+ UniqueLock l(update_lock_);
CHECK_EQ(state_, kInitialized) << "Illegal state for Start()."
<< " Replica is not in kInitialized state";
- lock->swap(&l);
+ lock->swap(l);
return Status::OK();
}
Status ReplicaState::LockForRead(UniqueLock* lock) const {
ThreadRestrictions::AssertWaitAllowed();
- UniqueLock l(&update_lock_);
- lock->swap(&l);
+ UniqueLock l(update_lock_);
+ lock->swap(l);
return Status::OK();
}
Status ReplicaState::LockForReplicate(UniqueLock* lock, const ReplicateMsg& msg) const {
ThreadRestrictions::AssertWaitAllowed();
DCHECK(!msg.has_id()) << "Should not have an ID yet: " << msg.ShortDebugString();
- UniqueLock l(&update_lock_);
+ UniqueLock l(update_lock_);
if (PREDICT_FALSE(state_ != kRunning)) {
return Status::IllegalState("Replica not in running state");
}
RETURN_NOT_OK(CheckActiveLeaderUnlocked());
- lock->swap(&l);
+ lock->swap(l);
return Status::OK();
}
Status ReplicaState::LockForCommit(UniqueLock* lock) const {
TRACE_EVENT0("consensus", "ReplicaState::LockForCommit");
ThreadRestrictions::AssertWaitAllowed();
- UniqueLock l(&update_lock_);
+ UniqueLock l(update_lock_);
if (PREDICT_FALSE(state_ != kRunning && state_ != kShuttingDown)) {
return Status::IllegalState("Replica not in running state");
}
- lock->swap(&l);
+ lock->swap(l);
return Status::OK();
}
Status ReplicaState::LockForMajorityReplicatedIndexUpdate(UniqueLock* lock) const {
TRACE_EVENT0("consensus", "ReplicaState::LockForMajorityReplicatedIndexUpdate");
ThreadRestrictions::AssertWaitAllowed();
- UniqueLock l(&update_lock_);
+ UniqueLock l(update_lock_);
if (PREDICT_FALSE(state_ != kRunning)) {
return Status::IllegalState("Replica not in running state");
@@ -128,7 +128,7 @@ Status ReplicaState::LockForMajorityReplicatedIndexUpdate(UniqueLock* lock) cons
if (PREDICT_FALSE(GetActiveRoleUnlocked() != RaftPeerPB::LEADER)) {
return Status::IllegalState("Replica not LEADER");
}
- lock->swap(&l);
+ lock->swap(l);
return Status::OK();
}
@@ -151,38 +151,38 @@ Status ReplicaState::LockForConfigChange(UniqueLock* lock) const {
TRACE_EVENT0("consensus", "ReplicaState::LockForConfigChange");
ThreadRestrictions::AssertWaitAllowed();
- UniqueLock l(&update_lock_);
+ UniqueLock l(update_lock_);
// Can only change the config on running replicas.
if (PREDICT_FALSE(state_ != kRunning)) {
return Status::IllegalState("Unable to lock ReplicaState for config change",
Substitute("State = $0", state_));
}
- lock->swap(&l);
+ lock->swap(l);
return Status::OK();
}
Status ReplicaState::LockForUpdate(UniqueLock* lock) const {
TRACE_EVENT0("consensus", "ReplicaState::LockForUpdate");
ThreadRestrictions::AssertWaitAllowed();
- UniqueLock l(&update_lock_);
+ UniqueLock l(update_lock_);
if (PREDICT_FALSE(state_ != kRunning)) {
return Status::IllegalState("Replica not in running state");
}
if (!IsRaftConfigVoter(peer_uuid_, ConsensusStateUnlocked(CONSENSUS_CONFIG_ACTIVE).config())) {
LOG_WITH_PREFIX_UNLOCKED(INFO) << "Allowing update even though not a member of the config";
}
- lock->swap(&l);
+ lock->swap(l);
return Status::OK();
}
Status ReplicaState::LockForShutdown(UniqueLock* lock) {
TRACE_EVENT0("consensus", "ReplicaState::LockForShutdown");
ThreadRestrictions::AssertWaitAllowed();
- UniqueLock l(&update_lock_);
+ UniqueLock l(update_lock_);
if (state_ != kShuttingDown && state_ != kShutDown) {
state_ = kShuttingDown;
}
- lock->swap(&l);
+ lock->swap(l);
return Status::OK();
}
@@ -366,7 +366,7 @@ int ReplicaState::GetNumPendingTxnsUnlocked() const {
Status ReplicaState::CancelPendingTransactions() {
{
ThreadRestrictions::AssertWaitAllowed();
- UniqueLock lock(&update_lock_);
+ UniqueLock lock(update_lock_);
if (state_ != kShuttingDown) {
return Status::IllegalState("Can only wait for pending commits on kShuttingDown state.");
}
@@ -723,7 +723,7 @@ ReplicaState::State ReplicaState::state() const {
string ReplicaState::ToString() const {
ThreadRestrictions::AssertWaitAllowed();
- ReplicaState::UniqueLock lock(&update_lock_);
+ ReplicaState::UniqueLock lock(update_lock_);
return ToStringUnlocked();
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/consensus/raft_consensus_state.h
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/raft_consensus_state.h b/src/kudu/consensus/raft_consensus_state.h
index a849cfc..2f7794b 100644
--- a/src/kudu/consensus/raft_consensus_state.h
+++ b/src/kudu/consensus/raft_consensus_state.h
@@ -18,6 +18,7 @@
#define KUDU_CONSENSUS_RAFT_CONSENSUS_UTIL_H_
#include <map>
+#include <mutex>
#include <set>
#include <string>
#include <utility>
@@ -86,7 +87,7 @@ class ReplicaState {
kShutDown
};
- typedef unique_lock<simple_spinlock> UniqueLock;
+ typedef std::unique_lock<simple_spinlock> UniqueLock;
typedef std::map<int64_t, scoped_refptr<ConsensusRound> > IndexToRoundMap;
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/fs/block_manager-stress-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/fs/block_manager-stress-test.cc b/src/kudu/fs/block_manager-stress-test.cc
index e1bc9dd..ad9cd9b 100644
--- a/src/kudu/fs/block_manager-stress-test.cc
+++ b/src/kudu/fs/block_manager-stress-test.cc
@@ -17,6 +17,7 @@
#include <cmath>
#include <memory>
+#include <mutex>
#include <string>
#include <vector>
@@ -253,7 +254,7 @@ void BlockManagerStressTest<T>::WriterThread() {
// Publish the now sync'ed blocks to readers and deleters.
{
- lock_guard<rw_spinlock> l(&lock_);
+ std::lock_guard<rw_spinlock> l(lock_);
for (WritableBlock* block : dirty_blocks) {
written_blocks_.push_back(block->id());
}
@@ -346,7 +347,7 @@ void BlockManagerStressTest<T>::DeleterThread() {
// Grab all the blocks we can.
vector<BlockId> to_delete;
{
- lock_guard<rw_spinlock> l(&lock_);
+ std::lock_guard<rw_spinlock> l(lock_);
to_delete.swap(written_blocks_);
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/fs/file_block_manager.cc
----------------------------------------------------------------------
diff --git a/src/kudu/fs/file_block_manager.cc b/src/kudu/fs/file_block_manager.cc
index 677a9af..226e107 100644
--- a/src/kudu/fs/file_block_manager.cc
+++ b/src/kudu/fs/file_block_manager.cc
@@ -477,7 +477,7 @@ Status FileBlockManager::SyncMetadata(const internal::FileBlockLocation& locatio
// Figure out what directories to sync.
vector<string> to_sync;
{
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
for (const string& parent_dir : parent_dirs) {
if (dirty_dirs_.erase(parent_dir)) {
to_sync.push_back(parent_dir);
@@ -649,7 +649,7 @@ Status FileBlockManager::CreateBlock(const CreateBlockOptions& opts,
uint16_t root_path_idx;
string root_path;
{
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
root_path_idx = next_root_path_->first;
root_path = next_root_path_->second->path();
next_root_path_++;
@@ -689,7 +689,7 @@ Status FileBlockManager::CreateBlock(const CreateBlockOptions& opts,
// Update dirty_dirs_ with those provided as well as the block's
// directory, which may not have been created but is definitely dirty
// (because we added a file to it).
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
for (const string& created : created_dirs) {
dirty_dirs_.insert(created);
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/fs/log_block_manager.cc
----------------------------------------------------------------------
diff --git a/src/kudu/fs/log_block_manager.cc b/src/kudu/fs/log_block_manager.cc
index 2036c94..6b983c3 100644
--- a/src/kudu/fs/log_block_manager.cc
+++ b/src/kudu/fs/log_block_manager.cc
@@ -17,6 +17,8 @@
#include "kudu/fs/log_block_manager.h"
+#include <mutex>
+
#include "kudu/fs/block_manager_metrics.h"
#include "kudu/fs/block_manager_util.h"
#include "kudu/gutil/callback.h"
@@ -498,7 +500,7 @@ Status LogBlockContainer::DeleteBlock(int64_t offset, int64_t length) {
// It is invalid to punch a zero-size hole.
if (length) {
- lock_guard<Mutex> l(&data_writer_lock_);
+ std::lock_guard<Mutex> l(data_writer_lock_);
// Round up to the nearest filesystem block so that the kernel will
// actually reclaim disk space.
//
@@ -513,7 +515,7 @@ Status LogBlockContainer::DeleteBlock(int64_t offset, int64_t length) {
Status LogBlockContainer::WriteData(int64_t offset, const Slice& data) {
DCHECK_GE(offset, 0);
- lock_guard<Mutex> l(&data_writer_lock_);
+ std::lock_guard<Mutex> l(data_writer_lock_);
return data_file_->Write(offset, data);
}
@@ -525,7 +527,7 @@ Status LogBlockContainer::ReadData(int64_t offset, size_t length,
}
Status LogBlockContainer::AppendMetadata(const BlockRecordPB& pb) {
- lock_guard<Mutex> l(&metadata_pb_writer_lock_);
+ std::lock_guard<Mutex> l(metadata_pb_writer_lock_);
return metadata_pb_writer_->Append(pb);
}
@@ -533,18 +535,18 @@ Status LogBlockContainer::FlushData(int64_t offset, int64_t length) {
DCHECK_GE(offset, 0);
DCHECK_GE(length, 0);
- lock_guard<Mutex> l(&data_writer_lock_);
+ std::lock_guard<Mutex> l(data_writer_lock_);
return data_file_->Flush(RWFile::FLUSH_ASYNC, offset, length);
}
Status LogBlockContainer::FlushMetadata() {
- lock_guard<Mutex> l(&metadata_pb_writer_lock_);
+ std::lock_guard<Mutex> l(metadata_pb_writer_lock_);
return metadata_pb_writer_->Flush();
}
Status LogBlockContainer::SyncData() {
if (FLAGS_enable_data_block_fsync) {
- lock_guard<Mutex> l(&data_writer_lock_);
+ std::lock_guard<Mutex> l(data_writer_lock_);
return data_file_->Sync();
}
return Status::OK();
@@ -552,7 +554,7 @@ Status LogBlockContainer::SyncData() {
Status LogBlockContainer::SyncMetadata() {
if (FLAGS_enable_data_block_fsync) {
- lock_guard<Mutex> l(&metadata_pb_writer_lock_);
+ std::lock_guard<Mutex> l(metadata_pb_writer_lock_);
return metadata_pb_writer_->Sync();
}
return Status::OK();
@@ -1209,7 +1211,7 @@ Status LogBlockManager::CreateBlock(const CreateBlockOptions& opts,
&new_container));
container = new_container.release();
{
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
dirty_dirs_.insert(root_path);
AddNewContainerUnlocked(container);
}
@@ -1244,7 +1246,7 @@ Status LogBlockManager::OpenBlock(const BlockId& block_id,
gscoped_ptr<ReadableBlock>* block) {
scoped_refptr<LogBlock> lb;
{
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
lb = FindPtrOrNull(blocks_by_block_id_, block_id);
}
if (!lb) {
@@ -1304,7 +1306,7 @@ Status LogBlockManager::CloseBlocks(const std::vector<WritableBlock*>& blocks) {
}
int64_t LogBlockManager::CountBlocksForTests() const {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
return blocks_by_block_id_.size();
}
@@ -1321,7 +1323,7 @@ void LogBlockManager::AddNewContainerUnlocked(LogBlockContainer* container) {
LogBlockContainer* LogBlockManager::GetAvailableContainer() {
LogBlockContainer* container = nullptr;
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
if (!available_containers_.empty()) {
container = available_containers_.front();
available_containers_.pop_front();
@@ -1330,7 +1332,7 @@ LogBlockContainer* LogBlockManager::GetAvailableContainer() {
}
void LogBlockManager::MakeContainerAvailable(LogBlockContainer* container) {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
MakeContainerAvailableUnlocked(container);
}
@@ -1346,7 +1348,7 @@ Status LogBlockManager::SyncContainer(const LogBlockContainer& container) {
Status s;
bool to_sync = false;
{
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
to_sync = dirty_dirs_.erase(container.dir());
}
@@ -1361,7 +1363,7 @@ Status LogBlockManager::SyncContainer(const LogBlockContainer& container) {
// In the worst case (another block synced this container as we did),
// we'll sync it again needlessly.
if (!s.ok()) {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
dirty_dirs_.insert(container.dir());
}
}
@@ -1373,7 +1375,7 @@ bool LogBlockManager::TryUseBlockId(const BlockId& block_id) {
return false;
}
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
if (ContainsKey(blocks_by_block_id_, block_id)) {
return false;
}
@@ -1384,7 +1386,7 @@ bool LogBlockManager::AddLogBlock(LogBlockContainer* container,
const BlockId& block_id,
int64_t offset,
int64_t length) {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
scoped_refptr<LogBlock> lb(new LogBlock(container, block_id, offset, length));
mem_tracker_->Consume(kudu_malloc_usable_size(lb.get()));
@@ -1409,7 +1411,7 @@ bool LogBlockManager::AddLogBlockUnlocked(const scoped_refptr<LogBlock>& lb) {
}
scoped_refptr<LogBlock> LogBlockManager::RemoveLogBlock(const BlockId& block_id) {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
scoped_refptr<LogBlock> result =
EraseKeyReturnValuePtr(&blocks_by_block_id_, block_id);
if (result) {
@@ -1509,7 +1511,7 @@ void LogBlockManager::OpenRootPath(const string& root_path,
// Under the lock, merge this map into the main block map and add
// the container.
{
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
// To avoid cacheline contention during startup, we aggregate all of the
// memory in a local and add it to the mem-tracker in a single increment
// at the end of this loop.
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/master/master_rpc.cc
----------------------------------------------------------------------
diff --git a/src/kudu/master/master_rpc.cc b/src/kudu/master/master_rpc.cc
index 60290a8..7e42cd3 100644
--- a/src/kudu/master/master_rpc.cc
+++ b/src/kudu/master/master_rpc.cc
@@ -20,6 +20,7 @@
#include "kudu/master/master_rpc.h"
#include <boost/bind.hpp>
+#include <mutex>
#include "kudu/common/wire_protocol.h"
#include "kudu/common/wire_protocol.pb.h"
@@ -133,7 +134,7 @@ string GetLeaderMasterRpc::ToString() const {
}
void GetLeaderMasterRpc::SendRpc() {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
for (int i = 0; i < addrs_.size(); i++) {
GetMasterRegistrationRpc* rpc = new GetMasterRegistrationRpc(
Bind(&GetLeaderMasterRpc::GetMasterRegistrationRpcCbForNode,
@@ -158,7 +159,7 @@ void GetLeaderMasterRpc::SendRpcCb(const Status& status) {
return;
}
{
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
// 'completed_' prevents 'user_cb_' from being invoked twice.
if (completed_) {
return;
@@ -180,7 +181,7 @@ void GetLeaderMasterRpc::GetMasterRegistrationRpcCbForNode(const Sockaddr& node_
// pick the one with the highest term/index as the leader.
Status new_status = status;
{
- lock_guard<simple_spinlock> lock(&lock_);
+ std::lock_guard<simple_spinlock> lock(lock_);
if (completed_) {
// If 'user_cb_' has been invoked (see SendRpcCb above), we can
// stop.
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/master/ts_descriptor.cc
----------------------------------------------------------------------
diff --git a/src/kudu/master/ts_descriptor.cc b/src/kudu/master/ts_descriptor.cc
index 1e5434b..80f500e 100644
--- a/src/kudu/master/ts_descriptor.cc
+++ b/src/kudu/master/ts_descriptor.cc
@@ -141,7 +141,7 @@ void TSDescriptor::DecayRecentReplicaCreationsUnlocked() {
}
void TSDescriptor::IncrementRecentReplicaCreations() {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
DecayRecentReplicaCreationsUnlocked();
recent_replica_creations_ += 1;
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/master/ts_descriptor.h
----------------------------------------------------------------------
diff --git a/src/kudu/master/ts_descriptor.h b/src/kudu/master/ts_descriptor.h
index b0327fc..3522d83 100644
--- a/src/kudu/master/ts_descriptor.h
+++ b/src/kudu/master/ts_descriptor.h
@@ -18,6 +18,7 @@
#define KUDU_MASTER_TS_DESCRIPTOR_H
#include <memory>
+#include <mutex>
#include <string>
#include "kudu/gutil/gscoped_ptr.h"
@@ -103,13 +104,13 @@ class TSDescriptor {
// Set the number of live replicas (i.e. running or bootstrapping).
void set_num_live_replicas(int n) {
DCHECK_GE(n, 0);
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
num_live_replicas_ = n;
}
// Return the number of live replicas (i.e running or bootstrapping).
int num_live_replicas() const {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
return num_live_replicas_;
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/rpc/messenger.cc
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/messenger.cc b/src/kudu/rpc/messenger.cc
index 2261217..3aff1dc 100644
--- a/src/kudu/rpc/messenger.cc
+++ b/src/kudu/rpc/messenger.cc
@@ -25,6 +25,7 @@
#include <gflags/gflags.h>
#include <glog/logging.h>
#include <list>
+#include <mutex>
#include <set>
#include <string>
@@ -132,7 +133,7 @@ void Messenger::Shutdown() {
// Since we're shutting down, it's OK to block.
ThreadRestrictions::ScopedAllowWait allow_wait;
- lock_guard<percpu_rwlock> guard(&lock_);
+ std::lock_guard<percpu_rwlock> guard(lock_);
if (closing_) {
return;
}
@@ -167,7 +168,7 @@ Status Messenger::AddAcceptorPool(const Sockaddr &accept_addr,
RETURN_NOT_OK(sock.GetSocketAddress(&remote));
shared_ptr<AcceptorPool> acceptor_pool(new AcceptorPool(this, &sock, remote));
- lock_guard<percpu_rwlock> guard(&lock_);
+ std::lock_guard<percpu_rwlock> guard(lock_);
acceptor_pools_.push_back(acceptor_pool);
*pool = acceptor_pool;
return Status::OK();
@@ -177,7 +178,7 @@ Status Messenger::AddAcceptorPool(const Sockaddr &accept_addr,
Status Messenger::RegisterService(const string& service_name,
const scoped_refptr<RpcService>& service) {
DCHECK(service);
- lock_guard<percpu_rwlock> guard(&lock_);
+ std::lock_guard<percpu_rwlock> guard(lock_);
if (InsertIfNotPresent(&rpc_services_, service_name, service)) {
return Status::OK();
} else {
@@ -186,14 +187,14 @@ Status Messenger::RegisterService(const string& service_name,
}
Status Messenger::UnregisterAllServices() {
- lock_guard<percpu_rwlock> guard(&lock_);
+ std::lock_guard<percpu_rwlock> guard(lock_);
rpc_services_.clear();
return Status::OK();
}
// Unregister an RpcService.
Status Messenger::UnregisterService(const string& service_name) {
- lock_guard<percpu_rwlock> guard(&lock_);
+ std::lock_guard<percpu_rwlock> guard(lock_);
if (rpc_services_.erase(service_name)) {
return Status::OK();
} else {
@@ -245,7 +246,7 @@ Messenger::Messenger(const MessengerBuilder &bld)
}
Messenger::~Messenger() {
- lock_guard<percpu_rwlock> guard(&lock_);
+ std::lock_guard<percpu_rwlock> guard(lock_);
CHECK(closing_) << "Should have already shut down";
STLDeleteElements(&reactors_);
}
@@ -298,7 +299,7 @@ void Messenger::ScheduleOnReactor(const boost::function<void(const Status&)>& fu
}
const scoped_refptr<RpcService> Messenger::rpc_service(const string& service_name) const {
- lock_guard<percpu_rwlock> guard(&lock_);
+ std::lock_guard<percpu_rwlock> guard(lock_);
scoped_refptr<RpcService> service;
if (FindCopy(rpc_services_, service_name, &service)) {
return service;
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/rpc/outbound_call.cc
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/outbound_call.cc b/src/kudu/rpc/outbound_call.cc
index c1abb26..19fc189 100644
--- a/src/kudu/rpc/outbound_call.cc
+++ b/src/kudu/rpc/outbound_call.cc
@@ -18,6 +18,7 @@
#include <algorithm>
#include <boost/functional/hash.hpp>
#include <gflags/gflags.h>
+#include <mutex>
#include <set>
#include <string>
#include <unordered_set>
@@ -113,12 +114,12 @@ void OutboundCall::SetRequestParam(const Message& message) {
}
Status OutboundCall::status() const {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
return status_;
}
const ErrorStatusPB* OutboundCall::error_pb() const {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
return error_pb_.get();
}
@@ -143,12 +144,12 @@ string OutboundCall::StateName(State state) {
}
void OutboundCall::set_state(State new_state) {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
set_state_unlocked(new_state);
}
OutboundCall::State OutboundCall::state() const {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
return state_;
}
@@ -249,7 +250,7 @@ void OutboundCall::SetSent() {
void OutboundCall::SetFailed(const Status &status,
ErrorStatusPB* err_pb) {
{
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
status_ = status;
if (status_.IsRemoteError()) {
CHECK(err_pb);
@@ -267,7 +268,7 @@ void OutboundCall::SetTimedOut() {
// order inversion between this class and RpcController.
MonoDelta timeout = controller_->timeout();
{
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
status_ = Status::TimedOut(Substitute(
"$0 RPC to $1 timed out after $2",
remote_method_.method_name(),
@@ -279,12 +280,12 @@ void OutboundCall::SetTimedOut() {
}
bool OutboundCall::IsTimedOut() const {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
return state_ == TIMED_OUT;
}
bool OutboundCall::IsFinished() const {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
switch (state_) {
case READY:
case ON_OUTBOUND_QUEUE:
@@ -306,7 +307,7 @@ string OutboundCall::ToString() const {
void OutboundCall::DumpPB(const DumpRunningRpcsRequestPB& req,
RpcCallInProgressPB* resp) {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
resp->mutable_header()->CopyFrom(header_);
resp->set_micros_elapsed(
MonoTime::Now(MonoTime::FINE) .GetDeltaSince(start_time_).ToMicroseconds());
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/rpc/reactor.cc
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/reactor.cc b/src/kudu/rpc/reactor.cc
index 434c965..bb8ed20 100644
--- a/src/kudu/rpc/reactor.cc
+++ b/src/kudu/rpc/reactor.cc
@@ -20,16 +20,15 @@
#include <arpa/inet.h>
#include <boost/intrusive/list.hpp>
#include <ev++.h>
+#include <glog/logging.h>
+#include <mutex>
#include <netinet/in.h>
#include <stdlib.h>
+#include <string>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
-#include <string>
-
-#include <glog/logging.h>
-
#include "kudu/gutil/ref_counted.h"
#include "kudu/gutil/stringprintf.h"
#include "kudu/rpc/connection.h"
@@ -491,7 +490,7 @@ Status Reactor::Init() {
void Reactor::Shutdown() {
{
- lock_guard<LockType> l(&lock_);
+ std::lock_guard<LockType> l(lock_);
if (closing_) {
return;
}
@@ -519,7 +518,7 @@ const std::string &Reactor::name() const {
}
bool Reactor::closing() const {
- lock_guard<LockType> l(&lock_);
+ std::lock_guard<LockType> l(lock_);
return closing_;
}
@@ -627,7 +626,7 @@ void Reactor::QueueOutboundCall(const shared_ptr<OutboundCall> &call) {
void Reactor::ScheduleReactorTask(ReactorTask *task) {
{
- unique_lock<LockType> l(&lock_);
+ std::unique_lock<LockType> l(lock_);
if (closing_) {
// We guarantee the reactor lock is not taken when calling Abort().
l.unlock();
@@ -640,7 +639,7 @@ void Reactor::ScheduleReactorTask(ReactorTask *task) {
}
bool Reactor::DrainTaskQueue(boost::intrusive::list<ReactorTask> *tasks) { // NOLINT(*)
- lock_guard<LockType> l(&lock_);
+ std::lock_guard<LockType> l(lock_);
if (closing_) {
return false;
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/rpc/request_tracker.cc
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/request_tracker.cc b/src/kudu/rpc/request_tracker.cc
index 4774c04..79e4578 100644
--- a/src/kudu/rpc/request_tracker.cc
+++ b/src/kudu/rpc/request_tracker.cc
@@ -16,6 +16,9 @@
// under the License.
#include "kudu/rpc/request_tracker.h"
+
+#include <mutex>
+
#include "kudu/gutil/map-util.h"
namespace kudu {
@@ -26,7 +29,7 @@ RequestTracker::RequestTracker(const string& client_id)
next_(0) {}
Status RequestTracker::NewSeqNo(SequenceNumber* seq_no) {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
*seq_no = next_;
InsertOrDie(&incomplete_rpcs_, *seq_no);
next_++;
@@ -34,14 +37,14 @@ Status RequestTracker::NewSeqNo(SequenceNumber* seq_no) {
}
Status RequestTracker::FirstIncomplete(SequenceNumber* seq_no) {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
if (incomplete_rpcs_.empty()) return Status::NotFound("There are no incomplete RPCs");
*seq_no = *incomplete_rpcs_.begin();
return Status::OK();
}
void RequestTracker::RpcCompleted(const SequenceNumber& seq_no) {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
incomplete_rpcs_.erase(seq_no);
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/rpc/rpc_controller.cc
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/rpc_controller.cc b/src/kudu/rpc/rpc_controller.cc
index 7236b0a..79a7380 100644
--- a/src/kudu/rpc/rpc_controller.cc
+++ b/src/kudu/rpc/rpc_controller.cc
@@ -15,10 +15,12 @@
// specific language governing permissions and limitations
// under the License.
+#include "kudu/rpc/rpc_controller.h"
+
#include <algorithm>
#include <glog/logging.h>
+#include <mutex>
-#include "kudu/rpc/rpc_controller.h"
#include "kudu/rpc/outbound_call.h"
namespace kudu { namespace rpc {
@@ -45,7 +47,7 @@ void RpcController::Swap(RpcController* other) {
}
void RpcController::Reset() {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
if (call_) {
CHECK(finished());
}
@@ -78,7 +80,7 @@ Status RpcController::GetSidecar(int idx, Slice* sidecar) const {
}
void RpcController::set_timeout(const MonoDelta& timeout) {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
DCHECK(!call_ || call_->state() == OutboundCall::READY);
timeout_ = timeout;
}
@@ -93,7 +95,7 @@ void RpcController::RequireServerFeature(uint32_t feature) {
}
MonoDelta RpcController::timeout() const {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
return timeout_;
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/rpc/rpcz_store.cc
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/rpcz_store.cc b/src/kudu/rpc/rpcz_store.cc
index 0587869..6b953d6 100644
--- a/src/kudu/rpc/rpcz_store.cc
+++ b/src/kudu/rpc/rpcz_store.cc
@@ -114,7 +114,7 @@ MethodSampler* RpczStore::SamplerForCall(InboundCall* call) {
// If missing, create a new sampler for this method and try to insert it.
unique_ptr<MethodSampler> ms(new MethodSampler());
- lock_guard<percpu_rwlock> lock(&samplers_lock_);
+ std::lock_guard<percpu_rwlock> lock(samplers_lock_);
auto it = method_samplers_.find(call->method_info());
if (it != method_samplers_.end()) {
return it->second.get();
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/rpc/service_queue.cc
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/service_queue.cc b/src/kudu/rpc/service_queue.cc
index e620683..9b938f6 100644
--- a/src/kudu/rpc/service_queue.cc
+++ b/src/kudu/rpc/service_queue.cc
@@ -16,6 +16,9 @@
// under the License.
#include "kudu/rpc/service_queue.h"
+
+#include <mutex>
+
#include "kudu/util/logging.h"
namespace kudu {
@@ -38,13 +41,13 @@ bool LifoServiceQueue::BlockingGet(std::unique_ptr<InboundCall>* out) {
auto consumer = tl_consumer_;
if (PREDICT_FALSE(!consumer)) {
consumer = tl_consumer_ = new ConsumerState(this);
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
consumers_.emplace_back(consumer);
}
while (true) {
{
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
if (!queue_.empty()) {
auto it = queue_.begin();
out->reset(*it);
@@ -69,7 +72,7 @@ bool LifoServiceQueue::BlockingGet(std::unique_ptr<InboundCall>* out) {
QueueStatus LifoServiceQueue::Put(InboundCall* call,
boost::optional<InboundCall*>* evicted) {
- unique_lock<simple_spinlock> l(&lock_);
+ std::unique_lock<simple_spinlock> l(lock_);
if (PREDICT_FALSE(shutdown_)) {
return QUEUE_SHUTDOWN;
}
@@ -105,7 +108,7 @@ QueueStatus LifoServiceQueue::Put(InboundCall* call,
}
void LifoServiceQueue::Shutdown() {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
shutdown_ = true;
// Post a nullptr to wake up any consumers which are waiting.
@@ -116,7 +119,7 @@ void LifoServiceQueue::Shutdown() {
}
bool LifoServiceQueue::empty() const {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
return queue_.empty();
}
@@ -127,7 +130,7 @@ int LifoServiceQueue::max_size() const {
std::string LifoServiceQueue::ToString() const {
std::string ret;
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
for (const auto* t : queue_) {
ret.append(t->ToString());
ret.append("\n");
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/tablet/delta_tracker.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/delta_tracker.cc b/src/kudu/tablet/delta_tracker.cc
index dc77a55..d155195 100644
--- a/src/kudu/tablet/delta_tracker.cc
+++ b/src/kudu/tablet/delta_tracker.cc
@@ -17,6 +17,7 @@
#include "kudu/tablet/delta_tracker.h"
+#include <mutex>
#include <set>
#include "kudu/gutil/strings/join.h"
@@ -154,7 +155,7 @@ Status DeltaTracker::AtomicUpdateStores(const SharedDeltaStoreVector& to_remove,
RETURN_NOT_OK_PREPEND(OpenDeltaReaders(new_delta_blocks, &new_stores, type),
"Unable to open delta blocks");
- lock_guard<rw_spinlock> lock(&component_lock_);
+ std::lock_guard<rw_spinlock> lock(component_lock_);
SharedDeltaStoreVector* stores_to_update =
type == REDO ? &redo_delta_stores_ : &undo_delta_stores_;
SharedDeltaStoreVector::iterator start_it;
@@ -197,7 +198,7 @@ Status DeltaTracker::CompactStores(int start_idx, int end_idx) {
// Prevent concurrent compactions or a compaction concurrent with a flush
//
// TODO(perf): this could be more fine grained
- lock_guard<Mutex> l(&compact_flush_lock_);
+ std::lock_guard<Mutex> l(compact_flush_lock_);
if (CountRedoDeltaStores() <= 1) {
return Status::OK();
}
@@ -272,7 +273,7 @@ Status DeltaTracker::DoCompactStores(size_t start_idx, size_t end_idx,
void DeltaTracker::CollectStores(vector<shared_ptr<DeltaStore>>* deltas,
WhichStores which) const {
- lock_guard<rw_spinlock> lock(&component_lock_);
+ std::lock_guard<rw_spinlock> lock(component_lock_);
if (which != REDOS_ONLY) {
deltas->assign(undo_delta_stores_.begin(), undo_delta_stores_.end());
}
@@ -298,7 +299,7 @@ Status DeltaTracker::NewDeltaFileIterator(
vector<shared_ptr<DeltaStore> >* included_stores,
unique_ptr<DeltaIterator>* out) const {
{
- lock_guard<rw_spinlock> lock(&component_lock_);
+ std::lock_guard<rw_spinlock> lock(component_lock_);
// TODO perf: is this really needed? Will check
// DeltaIteratorMerger::Create()
if (type == UNDO) {
@@ -414,7 +415,7 @@ Status DeltaTracker::FlushDMS(DeltaMemStore* dms,
}
Status DeltaTracker::Flush(MetadataFlushType flush_type) {
- lock_guard<Mutex> l(&compact_flush_lock_);
+ std::lock_guard<Mutex> l(compact_flush_lock_);
// First, swap out the old DeltaMemStore a new one,
// and add it to the list of delta stores to be reflected
@@ -424,7 +425,7 @@ Status DeltaTracker::Flush(MetadataFlushType flush_type) {
{
// Lock the component_lock_ in exclusive mode.
// This shuts out any concurrent readers or writers.
- lock_guard<rw_spinlock> lock(&component_lock_);
+ std::lock_guard<rw_spinlock> lock(component_lock_);
count = dms_->Count();
@@ -460,7 +461,7 @@ Status DeltaTracker::Flush(MetadataFlushType flush_type) {
// Now, re-take the lock and swap in the DeltaFileReader in place of
// of the DeltaMemStore
{
- lock_guard<rw_spinlock> lock(&component_lock_);
+ std::lock_guard<rw_spinlock> lock(component_lock_);
size_t idx = redo_delta_stores_.size() - 1;
CHECK_EQ(redo_delta_stores_[idx], old_dms)
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/tablet/maintenance_manager-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/maintenance_manager-test.cc b/src/kudu/tablet/maintenance_manager-test.cc
index 5bb5766..663ed47 100644
--- a/src/kudu/tablet/maintenance_manager-test.cc
+++ b/src/kudu/tablet/maintenance_manager-test.cc
@@ -18,6 +18,7 @@
#include <gflags/gflags.h>
#include <gtest/gtest.h>
#include <memory>
+#include <mutex>
#include <vector>
#include "kudu/gutil/strings/substitute.h"
@@ -100,7 +101,7 @@ class TestMaintenanceOp : public MaintenanceOp {
virtual ~TestMaintenanceOp() {}
virtual bool Prepare() OVERRIDE {
- lock_guard<Mutex> guard(&lock_);
+ std::lock_guard<Mutex> guard(lock_);
if (state_ != OP_RUNNABLE) {
return false;
}
@@ -112,14 +113,14 @@ class TestMaintenanceOp : public MaintenanceOp {
virtual void Perform() OVERRIDE {
DLOG(INFO) << "Performing op " << name();
- lock_guard<Mutex> guard(&lock_);
+ std::lock_guard<Mutex> guard(lock_);
CHECK_EQ(OP_RUNNING, state_);
state_ = OP_FINISHED;
state_change_cond_.Broadcast();
}
virtual void UpdateStats(MaintenanceOpStats* stats) OVERRIDE {
- lock_guard<Mutex> guard(&lock_);
+ std::lock_guard<Mutex> guard(lock_);
stats->set_runnable(state_ == OP_RUNNABLE);
stats->set_ram_anchored(consumption_.consumption());
stats->set_logs_retained_bytes(logs_retained_bytes_);
@@ -127,14 +128,14 @@ class TestMaintenanceOp : public MaintenanceOp {
}
void Enable() {
- lock_guard<Mutex> guard(&lock_);
+ std::lock_guard<Mutex> guard(lock_);
DCHECK((state_ == OP_DISABLED) || (state_ == OP_FINISHED));
state_ = OP_RUNNABLE;
state_change_cond_.Broadcast();
}
void WaitForState(TestMaintenanceOpState state) {
- lock_guard<Mutex> guard(&lock_);
+ std::lock_guard<Mutex> guard(lock_);
while (true) {
if (state_ == state) {
return;
@@ -145,7 +146,7 @@ class TestMaintenanceOp : public MaintenanceOp {
bool WaitForStateWithTimeout(TestMaintenanceOpState state, int ms) {
MonoDelta to_wait = MonoDelta::FromMilliseconds(ms);
- lock_guard<Mutex> guard(&lock_);
+ std::lock_guard<Mutex> guard(lock_);
while (true) {
if (state_ == state) {
return true;
@@ -157,17 +158,17 @@ class TestMaintenanceOp : public MaintenanceOp {
}
void set_ram_anchored(uint64_t ram_anchored) {
- lock_guard<Mutex> guard(&lock_);
+ std::lock_guard<Mutex> guard(lock_);
consumption_.Reset(ram_anchored);
}
void set_logs_retained_bytes(uint64_t logs_retained_bytes) {
- lock_guard<Mutex> guard(&lock_);
+ std::lock_guard<Mutex> guard(lock_);
logs_retained_bytes_ = logs_retained_bytes;
}
void set_perf_improvement(uint64_t perf_improvement) {
- lock_guard<Mutex> guard(&lock_);
+ std::lock_guard<Mutex> guard(lock_);
perf_improvement_ = perf_improvement;
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/tablet/maintenance_manager.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/maintenance_manager.cc b/src/kudu/tablet/maintenance_manager.cc
index 780d917..b611e10 100644
--- a/src/kudu/tablet/maintenance_manager.cc
+++ b/src/kudu/tablet/maintenance_manager.cc
@@ -127,7 +127,7 @@ Status MaintenanceManager::Init() {
void MaintenanceManager::Shutdown() {
{
- lock_guard<Mutex> guard(&lock_);
+ std::lock_guard<Mutex> guard(lock_);
if (shutdown_) {
return;
}
@@ -142,7 +142,7 @@ void MaintenanceManager::Shutdown() {
}
void MaintenanceManager::RegisterOp(MaintenanceOp* op) {
- lock_guard<Mutex> guard(&lock_);
+ std::lock_guard<Mutex> guard(lock_);
CHECK(!op->manager_.get()) << "Tried to register " << op->name()
<< ", but it was already registered.";
pair<OpMapTy::iterator, bool> val
@@ -157,7 +157,7 @@ void MaintenanceManager::RegisterOp(MaintenanceOp* op) {
void MaintenanceManager::UnregisterOp(MaintenanceOp* op) {
{
- lock_guard<Mutex> guard(&lock_);
+ std::lock_guard<Mutex> guard(lock_);
CHECK(op->manager_.get() == this) << "Tried to unregister " << op->name()
<< ", but it is not currently registered with this maintenance manager.";
auto iter = ops_.find(op);
@@ -186,7 +186,7 @@ void MaintenanceManager::UnregisterOp(MaintenanceOp* op) {
void MaintenanceManager::RunSchedulerThread() {
MonoDelta polling_interval = MonoDelta::FromMilliseconds(polling_interval_ms_);
- unique_lock<Mutex> guard(&lock_);
+ std::unique_lock<Mutex> guard(lock_);
while (true) {
// Loop until we are shutting down or it is time to run another op.
cond_.TimedWait(polling_interval);
@@ -362,7 +362,7 @@ void MaintenanceManager::LaunchOp(MaintenanceOp* op) {
op->RunningGauge()->Decrement();
MonoTime end_time(MonoTime::Now(MonoTime::FINE));
MonoDelta delta(end_time.GetDeltaSince(start_time));
- lock_guard<Mutex> guard(&lock_);
+ std::lock_guard<Mutex> guard(lock_);
CompletedOp& completed_op = completed_ops_[completed_ops_count_ % completed_ops_.size()];
completed_op.name = op->name();
@@ -379,7 +379,7 @@ void MaintenanceManager::LaunchOp(MaintenanceOp* op) {
void MaintenanceManager::GetMaintenanceManagerStatusDump(MaintenanceManagerStatusPB* out_pb) {
DCHECK(out_pb != nullptr);
- lock_guard<Mutex> guard(&lock_);
+ std::lock_guard<Mutex> guard(lock_);
MaintenanceOp* best_op = FindBestOp();
for (MaintenanceManager::OpMapTy::value_type& val : ops_) {
MaintenanceManagerStatusPB_MaintenanceOpPB* op_pb = out_pb->add_registered_operations();
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/tablet/mvcc.h
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/mvcc.h b/src/kudu/tablet/mvcc.h
index ffa736a..1863e13 100644
--- a/src/kudu/tablet/mvcc.h
+++ b/src/kudu/tablet/mvcc.h
@@ -18,6 +18,7 @@
#define KUDU_TABLET_MVCC_H
#include <gtest/gtest_prod.h>
+#include <mutex>
#include <string>
#include <unordered_map>
#include <vector>
@@ -367,7 +368,7 @@ class MvccManager {
void AdvanceEarliestInFlightTimestamp();
int GetNumWaitersForTests() const {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
return waiters_.size();
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/tablet/rowset_metadata.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/rowset_metadata.cc b/src/kudu/tablet/rowset_metadata.cc
index 042cdef..57be903 100644
--- a/src/kudu/tablet/rowset_metadata.cc
+++ b/src/kudu/tablet/rowset_metadata.cc
@@ -17,6 +17,7 @@
#include "kudu/tablet/rowset_metadata.h"
+#include <mutex>
#include <string>
#include <utility>
#include <vector>
@@ -93,7 +94,7 @@ Status RowSetMetadata::InitFromPB(const RowSetDataPB& pb) {
void RowSetMetadata::ToProtobuf(RowSetDataPB *pb) {
pb->set_id(id_);
- lock_guard<LockType> l(&lock_);
+ std::lock_guard<LockType> l(lock_);
// Write Column Files
for (const ColumnIdToBlockIdMap::value_type& e : blocks_by_col_id_) {
@@ -134,20 +135,20 @@ const string RowSetMetadata::ToString() const {
}
void RowSetMetadata::SetColumnDataBlocks(const ColumnIdToBlockIdMap& blocks) {
- lock_guard<LockType> l(&lock_);
+ std::lock_guard<LockType> l(lock_);
blocks_by_col_id_ = blocks;
}
Status RowSetMetadata::CommitRedoDeltaDataBlock(int64_t dms_id,
const BlockId& block_id) {
- lock_guard<LockType> l(&lock_);
+ std::lock_guard<LockType> l(lock_);
last_durable_redo_dms_id_ = dms_id;
redo_delta_blocks_.push_back(block_id);
return Status::OK();
}
Status RowSetMetadata::CommitUndoDeltaDataBlock(const BlockId& block_id) {
- lock_guard<LockType> l(&lock_);
+ std::lock_guard<LockType> l(lock_);
undo_delta_blocks_.push_back(block_id);
return Status::OK();
}
@@ -155,7 +156,7 @@ Status RowSetMetadata::CommitUndoDeltaDataBlock(const BlockId& block_id) {
Status RowSetMetadata::CommitUpdate(const RowSetMetadataUpdate& update) {
vector<BlockId> removed;
{
- lock_guard<LockType> l(&lock_);
+ std::lock_guard<LockType> l(lock_);
for (const RowSetMetadataUpdate::ReplaceDeltaBlocks rep :
update.replace_redo_blocks_) {
@@ -216,7 +217,7 @@ Status RowSetMetadata::CommitUpdate(const RowSetMetadataUpdate& update) {
vector<BlockId> RowSetMetadata::GetAllBlocks() {
vector<BlockId> blocks;
- lock_guard<LockType> l(&lock_);
+ std::lock_guard<LockType> l(lock_);
if (!adhoc_index_block_.IsNull()) {
blocks.push_back(adhoc_index_block_);
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/tablet/rowset_metadata.h
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/rowset_metadata.h b/src/kudu/tablet/rowset_metadata.h
index d84f608..14ed190 100644
--- a/src/kudu/tablet/rowset_metadata.h
+++ b/src/kudu/tablet/rowset_metadata.h
@@ -18,6 +18,7 @@
#define KUDU_TABLET_ROWSET_METADATA_H
#include <map>
+#include <mutex>
#include <string>
#include <vector>
@@ -89,13 +90,13 @@ class RowSetMetadata {
}
void set_bloom_block(const BlockId& block_id) {
- lock_guard<LockType> l(&lock_);
+ std::lock_guard<LockType> l(lock_);
DCHECK(bloom_block_.IsNull());
bloom_block_ = block_id;
}
void set_adhoc_index_block(const BlockId& block_id) {
- lock_guard<LockType> l(&lock_);
+ std::lock_guard<LockType> l(lock_);
DCHECK(adhoc_index_block_.IsNull());
adhoc_index_block_ = block_id;
}
@@ -107,61 +108,61 @@ class RowSetMetadata {
Status CommitUndoDeltaDataBlock(const BlockId& block_id);
BlockId bloom_block() const {
- lock_guard<LockType> l(&lock_);
+ std::lock_guard<LockType> l(lock_);
return bloom_block_;
}
BlockId adhoc_index_block() const {
- lock_guard<LockType> l(&lock_);
+ std::lock_guard<LockType> l(lock_);
return adhoc_index_block_;
}
bool has_adhoc_index_block() const {
- lock_guard<LockType> l(&lock_);
+ std::lock_guard<LockType> l(lock_);
return !adhoc_index_block_.IsNull();
}
BlockId column_data_block_for_col_id(ColumnId col_id) {
- lock_guard<LockType> l(&lock_);
+ std::lock_guard<LockType> l(lock_);
return FindOrDie(blocks_by_col_id_, col_id);
}
ColumnIdToBlockIdMap GetColumnBlocksById() const {
- lock_guard<LockType> l(&lock_);
+ std::lock_guard<LockType> l(lock_);
return blocks_by_col_id_;
}
vector<BlockId> redo_delta_blocks() const {
- lock_guard<LockType> l(&lock_);
+ std::lock_guard<LockType> l(lock_);
return redo_delta_blocks_;
}
vector<BlockId> undo_delta_blocks() const {
- lock_guard<LockType> l(&lock_);
+ std::lock_guard<LockType> l(lock_);
return undo_delta_blocks_;
}
TabletMetadata *tablet_metadata() const { return tablet_metadata_; }
int64_t last_durable_redo_dms_id() const {
- lock_guard<LockType> l(&lock_);
+ std::lock_guard<LockType> l(lock_);
return last_durable_redo_dms_id_;
}
void SetLastDurableRedoDmsIdForTests(int64_t redo_dms_id) {
- lock_guard<LockType> l(&lock_);
+ std::lock_guard<LockType> l(lock_);
last_durable_redo_dms_id_ = redo_dms_id;
}
bool HasDataForColumnIdForTests(ColumnId col_id) const {
BlockId b;
- lock_guard<LockType> l(&lock_);
+ std::lock_guard<LockType> l(lock_);
if (!FindCopy(blocks_by_col_id_, col_id, &b)) return false;
return fs_manager()->BlockExists(b);
}
bool HasBloomDataBlockForTests() const {
- lock_guard<LockType> l(&lock_);
+ std::lock_guard<LockType> l(lock_);
return !bloom_block_.IsNull() && fs_manager()->BlockExists(bloom_block_);
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/tablet/tablet_peer.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/tablet_peer.cc b/src/kudu/tablet/tablet_peer.cc
index 47aefc8..a6d7b70 100644
--- a/src/kudu/tablet/tablet_peer.cc
+++ b/src/kudu/tablet/tablet_peer.cc
@@ -188,7 +188,7 @@ Status TabletPeer::Init(const shared_ptr<Tablet>& tablet,
}
Status TabletPeer::Start(const ConsensusBootstrapInfo& bootstrap_info) {
- lock_guard<simple_spinlock> l(&state_change_lock_);
+ std::lock_guard<simple_spinlock> l(state_change_lock_);
TRACE("Starting consensus");
VLOG(2) << "T " << tablet_id() << " P " << consensus_->peer_uuid() << ": Peer starting";
@@ -218,7 +218,7 @@ void TabletPeer::Shutdown() {
LOG(INFO) << "Initiating TabletPeer shutdown for tablet: " << tablet_id_;
{
- unique_lock<simple_spinlock> lock(&lock_);
+ std::unique_lock<simple_spinlock> lock(lock_);
if (state_ == QUIESCING || state_ == SHUTDOWN) {
lock.unlock();
WaitUntilShutdown();
@@ -227,7 +227,7 @@ void TabletPeer::Shutdown() {
state_ = QUIESCING;
}
- lock_guard<simple_spinlock> l(&state_change_lock_);
+ std::lock_guard<simple_spinlock> l(state_change_lock_);
// Even though Tablet::Shutdown() also unregisters its ops, we have to do it here
// to ensure that any currently running operation finishes before we proceed with
// the rest of the shutdown sequence. In particular, a maintenance operation could
@@ -565,7 +565,7 @@ Status TabletPeer::NewReplicaTransactionDriver(gscoped_ptr<Transaction> transact
void TabletPeer::RegisterMaintenanceOps(MaintenanceManager* maint_mgr) {
// Taking state_change_lock_ ensures that we don't shut down concurrently with
// this last start-up task.
- lock_guard<simple_spinlock> l(&state_change_lock_);
+ std::lock_guard<simple_spinlock> l(state_change_lock_);
if (state() != RUNNING) {
LOG(WARNING) << "Not registering maintenance operations for " << tablet_
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/tablet/transactions/transaction.h
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/transactions/transaction.h b/src/kudu/tablet/transactions/transaction.h
index dc49fd3..2a10f23 100644
--- a/src/kudu/tablet/transactions/transaction.h
+++ b/src/kudu/tablet/transactions/transaction.h
@@ -19,6 +19,7 @@
#define KUDU_TABLET_TRANSACTION_H_
#include <string>
+#include <mutex>
#include "kudu/common/timestamp.h"
#include "kudu/common/wire_protocol.h"
@@ -195,19 +196,19 @@ class TransactionState {
// Sets the timestamp for the transaction
virtual void set_timestamp(const Timestamp& timestamp) {
// make sure we set the timestamp only once
- lock_guard<simple_spinlock> l(&txn_state_lock_);
+ std::lock_guard<simple_spinlock> l(txn_state_lock_);
DCHECK_EQ(timestamp_, Timestamp::kInvalidTimestamp);
timestamp_ = timestamp;
}
Timestamp timestamp() const {
- lock_guard<simple_spinlock> l(&txn_state_lock_);
+ std::lock_guard<simple_spinlock> l(txn_state_lock_);
DCHECK(timestamp_ != Timestamp::kInvalidTimestamp);
return timestamp_;
}
bool has_timestamp() const {
- lock_guard<simple_spinlock> l(&txn_state_lock_);
+ std::lock_guard<simple_spinlock> l(txn_state_lock_);
return timestamp_ != Timestamp::kInvalidTimestamp;
}
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/8a75ceee/src/kudu/tablet/transactions/transaction_tracker.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/transactions/transaction_tracker.cc b/src/kudu/tablet/transactions/transaction_tracker.cc
index ca21cd5..17887ec 100644
--- a/src/kudu/tablet/transactions/transaction_tracker.cc
+++ b/src/kudu/tablet/transactions/transaction_tracker.cc
@@ -86,7 +86,7 @@ TransactionTracker::TransactionTracker() {
}
TransactionTracker::~TransactionTracker() {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
CHECK_EQ(pending_txns_.size(), 0);
if (mem_tracker_) {
mem_tracker_->UnregisterFromParent();
@@ -120,7 +120,7 @@ Status TransactionTracker::Add(TransactionDriver* driver) {
// again, as it may disappear between now and then.
State st;
st.memory_footprint = driver_mem_footprint;
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
InsertOrDie(&pending_txns_, driver, st);
return Status::OK();
}
@@ -167,7 +167,7 @@ void TransactionTracker::Release(TransactionDriver* driver) {
{
// Remove the transaction from the map, retaining the state for use
// below.
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
st = FindOrDie(pending_txns_, driver);
if (PREDICT_FALSE(pending_txns_.erase(driver) != 1)) {
LOG(FATAL) << "Could not remove pending transaction from map: "
@@ -183,7 +183,7 @@ void TransactionTracker::Release(TransactionDriver* driver) {
void TransactionTracker::GetPendingTransactions(
vector<scoped_refptr<TransactionDriver> >* pending_out) const {
DCHECK(pending_out->empty());
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
for (const TxnMap::value_type& e : pending_txns_) {
// Increments refcount of each transaction.
pending_out->push_back(e.first);
@@ -191,7 +191,7 @@ void TransactionTracker::GetPendingTransactions(
}
int TransactionTracker::GetNumPendingForTests() const {
- lock_guard<simple_spinlock> l(&lock_);
+ std::lock_guard<simple_spinlock> l(lock_);
return pending_txns_.size();
}