Skip to content

Commit

Permalink
[refactor] Remove boost mutex, use std::mutex instead (apache#5684)
Browse files Browse the repository at this point in the history
* Remove boost mutex, use std::mutex instead

* replace shared_mutex
  • Loading branch information
yangzhg authored Apr 22, 2021
1 parent 8332581 commit a803cee
Show file tree
Hide file tree
Showing 72 changed files with 360 additions and 580 deletions.
4 changes: 2 additions & 2 deletions be/src/agent/topic_subscriber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ TopicSubscriber::~TopicSubscriber() {

void TopicSubscriber::register_listener(TTopicType::type topic_type, TopicListener* listener) {
// Unique lock here to prevent access to listeners
boost::unique_lock<boost::shared_mutex> lock(_listener_mtx);
std::unique_lock<std::shared_mutex> lock(_listener_mtx);
this->_registered_listeners[topic_type].push_back(listener);
}

void TopicSubscriber::handle_updates(const TAgentPublishRequest& agent_publish_request) {
// Shared lock here in order to avoid updates in listeners' map
boost::shared_lock<boost::shared_mutex> lock(_listener_mtx);
std::shared_lock<std::shared_mutex> lock(_listener_mtx);
// Currently, not deal with protocol version, the listener should deal with protocol version
const std::vector<TTopicUpdate>& topic_updates = agent_publish_request.updates;
std::vector<TTopicUpdate>::const_iterator topic_update_it = topic_updates.begin();
Expand Down
3 changes: 2 additions & 1 deletion be/src/agent/topic_subscriber.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include <boost/thread.hpp>
#include <map>
#include <shared_mutex>

#include "agent/topic_listener.h"
#include "gen_cpp/AgentService_types.h"
Expand All @@ -37,7 +38,7 @@ class TopicSubscriber {

private:
std::map<TTopicType::type, std::vector<TopicListener*>> _registered_listeners;
boost::shared_mutex _listener_mtx;
std::shared_mutex _listener_mtx;
};
} // namespace doris
#endif
174 changes: 0 additions & 174 deletions be/src/common/names.h

This file was deleted.

7 changes: 3 additions & 4 deletions be/src/common/object_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
#ifndef DORIS_BE_SRC_COMMON_COMMON_OBJECT_POOL_H
#define DORIS_BE_SRC_COMMON_COMMON_OBJECT_POOL_H

#include <boost/thread/locks.hpp>
#include <boost/thread/mutex.hpp>
#include <mutex>
#include <vector>

#include "util/spinlock.h"
Expand All @@ -41,13 +40,13 @@ class ObjectPool {
// TODO: Consider using a lock-free structure.
SpecificElement<T>* obj = new SpecificElement<T>(t);
DCHECK(obj != NULL);
boost::lock_guard<SpinLock> l(_lock);
std::lock_guard<SpinLock> l(_lock);
_objects.push_back(obj);
return t;
}

void clear() {
boost::lock_guard<SpinLock> l(_lock);
std::lock_guard<SpinLock> l(_lock);
for (auto i = _objects.rbegin(); i != _objects.rend(); ++i) {
delete *i;
}
Expand Down
2 changes: 1 addition & 1 deletion be/src/exec/cross_join_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

#include <boost/scoped_ptr.hpp>
#include <boost/thread.hpp>
#include <boost/unordered_set.hpp>
#include <string>
#include <unordered_set>

#include "exec/blocking_join_node.h"
#include "exec/exec_node.h"
Expand Down
6 changes: 3 additions & 3 deletions be/src/exec/exec_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ using std::string;
using std::stringstream;
using std::vector;
using std::map;
using boost::lock_guard;
using boost::mutex;
using std::lock_guard;
using std::mutex;

// Superclass of all executor nodes.
// All subclasses need to make sure to check RuntimeState::is_cancelled()
Expand Down Expand Up @@ -304,7 +304,7 @@ class ExecNode {
// Execution options that are determined at runtime. This is added to the
// runtime profile at close(). Examples for options logged here would be
// "Codegen Enabled"
boost::mutex _exec_options_lock;
std::mutex _exec_options_lock;
std::string _runtime_exec_options;

/// Buffer pool client for this node. Initialized with the node's minimum reservation
Expand Down
6 changes: 3 additions & 3 deletions be/src/exec/hash_join_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

#include <boost/scoped_ptr.hpp>
#include <boost/thread.hpp>
#include <boost/unordered_set.hpp>
#include <string>
#include <unordered_set>

#include "exec/exec_node.h"
#include "exec/hash_table.h"
Expand Down Expand Up @@ -67,7 +67,7 @@ class HashJoinNode : public ExecNode {
bool _is_push_down;

// for right outer joins, keep track of what's been joined
typedef boost::unordered_set<TupleRow*> BuildTupleRowSet;
typedef std::unordered_set<TupleRow*> BuildTupleRowSet;
BuildTupleRowSet _joined_build_rows;

TJoinOp::type _join_op;
Expand Down Expand Up @@ -106,7 +106,7 @@ class HashJoinNode : public ExecNode {
boost::scoped_ptr<RowBatch> _probe_batch;
int _probe_batch_pos; // current scan pos in _probe_batch
int _probe_counter;
bool _probe_eos; // if true, probe child has no more rows to process
bool _probe_eos; // if true, probe child has no more rows to process
TupleRow* _current_probe_row;

// _build_tuple_idx[i] is the tuple index of child(1)'s tuple[i] in the output row
Expand Down
2 changes: 1 addition & 1 deletion be/src/exec/merge_join_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

#include <boost/scoped_ptr.hpp>
#include <boost/thread.hpp>
#include <boost/unordered_set.hpp>
#include <string>
#include <unordered_set>

#include "exec/exec_node.h"
#include "gen_cpp/PlanNodes_types.h" // for TJoinOp
Expand Down
1 change: 0 additions & 1 deletion be/src/exec/schema_scanner/schema_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include "exec/schema_scanner/schema_helper.h"

#include <boost/functional/hash.hpp>
#include <boost/thread/locks.hpp>
#include <boost/thread/thread.hpp>
#include <sstream>

Expand Down
2 changes: 0 additions & 2 deletions be/src/exprs/agg_fn_evaluator.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,6 @@ class AggFnEvaluator {
static const size_t DOUBLE_SIZE = sizeof(double);
static const size_t DECIMAL_SIZE = sizeof(DecimalValue);
static const size_t DECIMALV2_SIZE = sizeof(DecimalV2Value);
static const size_t TIME_DURATION_SIZE = sizeof(boost::posix_time::time_duration);
static const size_t DATE_SIZE = sizeof(boost::gregorian::date);
static const size_t LARGEINT_SIZE = sizeof(__int128);
// DATETIME VAL has two part: packet_time is 8 byte, and type is 4 byte
// MySQL packet time : int64_t packed_time;
Expand Down
2 changes: 1 addition & 1 deletion be/src/exprs/in_predicate.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#define DORIS_BE_SRC_QUERY_EXPRS_IN_PREDICATE_H

#include <boost/shared_ptr.hpp>
#include <boost/unordered_set.hpp>
#include <string>
#include <unordered_set>

#include "exprs/hybrid_set.h"
#include "exprs/predicate.h"
Expand Down
2 changes: 0 additions & 2 deletions be/src/exprs/new_agg_fn_evaluator.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,6 @@ class NewAggFnEvaluator {
static const size_t DOUBLE_SIZE = sizeof(double);
static const size_t DECIMAL_SIZE = sizeof(DecimalValue);
static const size_t DECIMALV2_SIZE = sizeof(DecimalV2Value);
static const size_t TIME_DURATION_SIZE = sizeof(boost::posix_time::time_duration);
static const size_t DATE_SIZE = sizeof(boost::gregorian::date);
static const size_t LARGEINT_SIZE = sizeof(__int128);

// DATETIME VAL has two part: packet_time is 8 byte, and type is 4 byte
Expand Down
2 changes: 1 addition & 1 deletion be/src/exprs/new_in_predicate.h
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ class InPredicate {
bool contains_null;

/// The set of all non-NULL constant values in the IN list.
/// Note: boost::unordered_set and std::binary_search performed worse based on the
/// Note: std::unordered_set and std::binary_search performed worse based on the
/// in-predicate-benchmark
std::set<SetType> val_set;

Expand Down
1 change: 0 additions & 1 deletion be/src/http/action/restore_tablet_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <string>

#include "agent/cgroups_mgr.h"
#include "boost/lexical_cast.hpp"
#include "env/env.h"
#include "gutil/strings/substitute.h" // for Substitute
#include "http/http_channel.h"
Expand Down
4 changes: 2 additions & 2 deletions be/src/http/web_page_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void WebPageHandler::register_template_page(const std::string& path, const strin

void WebPageHandler::register_page(const std::string& path, const string& alias,
const PageHandlerCallback& callback, bool is_on_nav_bar) {
boost::mutex::scoped_lock lock(_map_lock);
std::unique_lock lock(_map_lock);
CHECK(_page_map.find(path) == _page_map.end());
// first time, register this to web server
_http_server->register_handler(HttpMethod::GET, path, this);
Expand All @@ -85,7 +85,7 @@ void WebPageHandler::handle(HttpRequest* req) {
VLOG_TRACE << req->debug_string();
PathHandler* handler = nullptr;
{
boost::mutex::scoped_lock lock(_map_lock);
std::unique_lock lock(_map_lock);
auto iter = _page_map.find(req->raw_path());
if (iter != _page_map.end()) {
handler = iter->second;
Expand Down
4 changes: 2 additions & 2 deletions be/src/http/web_page_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#define DORIS_BE_SRC_COMMON_UTIL_WEB_PAGE_HANDLER_H

#include <boost/function.hpp>
#include <boost/thread/mutex.hpp>
#include <map>
#include <mutex>
#include <sstream>
#include <string>
#include <vector>
Expand Down Expand Up @@ -112,7 +112,7 @@ class WebPageHandler : public HttpHandler {
std::string _www_path;
EvHttpServer* _http_server;
// Lock guarding the _path_handlers map
boost::mutex _map_lock;
std::mutex _map_lock;
// Map of path to a PathHandler containing a list of handlers for that
// path. More than one handler may register itself with a path so that many
// components may contribute to a single page.
Expand Down
Loading

0 comments on commit a803cee

Please sign in to comment.