Skip to content

Commit 375b0c4

Browse files
committed
Merge branch 'support-for-mysql-56-57-plus-boost-to-std'
2 parents 5340ecf + f113cb5 commit 375b0c4

12 files changed

+68
-70
lines changed

Diff for: CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ ENDIF (CMAKE_COMPILER_IS_GNUCC)
1414

1515
FIND_PACKAGE (Boost REQUIRED)
1616
INCLUDE_DIRECTORIES (${Boost_INCLUDE_DIRS})
17-
FIND_PACKAGE (Boost 1.41.0 COMPONENTS unit_test_framework thread system)
17+
FIND_PACKAGE (Boost 1.41.0 COMPONENTS unit_test_framework system)
1818

1919
INCLUDE (FindPackageHandleStandardArgs)
2020
FIND_PATH (IMYSQL mysql/mysql.h)

Diff for: DefaultExtState.h

+19-19
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,99 @@
11
#ifndef __SLAVE_DEFAULTEXTSTATE_H_
22
#define __SLAVE_DEFAULTEXTSTATE_H_
33

4-
#include "SlaveStats.h"
4+
#include <mutex>
55

6-
#include <boost/thread/mutex.hpp>
6+
#include "SlaveStats.h"
77

88
namespace slave
99
{
1010
class DefaultExtState: public ExtStateIface, protected State {
11-
boost::mutex m_mutex;
11+
std::mutex m_mutex;
1212

1313
public:
1414
virtual State getState()
1515
{
16-
boost::mutex::scoped_lock lock(m_mutex);
16+
std::lock_guard<std::mutex> lock(m_mutex);
1717
return *this;
1818
}
1919
virtual void setConnecting()
2020
{
21-
boost::mutex::scoped_lock lock(m_mutex);
21+
std::lock_guard<std::mutex> lock(m_mutex);
2222
connect_time = ::time(NULL);
2323
++connect_count;
2424
}
2525
virtual time_t getConnectTime()
2626
{
27-
boost::mutex::scoped_lock lock(m_mutex);
27+
std::lock_guard<std::mutex> lock(m_mutex);
2828
return connect_time;
2929
}
3030
virtual void setLastFilteredUpdateTime()
3131
{
32-
boost::mutex::scoped_lock lock(m_mutex);
32+
std::lock_guard<std::mutex> lock(m_mutex);
3333
last_filtered_update = ::time(NULL);
3434
}
3535
virtual time_t getLastFilteredUpdateTime()
3636
{
37-
boost::mutex::scoped_lock lock(m_mutex);
37+
std::lock_guard<std::mutex> lock(m_mutex);
3838
return last_filtered_update;
3939
}
4040
virtual void setLastEventTimePos(time_t t, unsigned long pos)
4141
{
42-
boost::mutex::scoped_lock lock(m_mutex);
42+
std::lock_guard<std::mutex> lock(m_mutex);
4343
last_event_time = t; intransaction_pos = pos; last_update = ::time(NULL);
4444
}
4545
virtual time_t getLastUpdateTime()
4646
{
47-
boost::mutex::scoped_lock lock(m_mutex);
47+
std::lock_guard<std::mutex> lock(m_mutex);
4848
return last_update;
4949
}
5050
virtual time_t getLastEventTime()
5151
{
52-
boost::mutex::scoped_lock lock(m_mutex);
52+
std::lock_guard<std::mutex> lock(m_mutex);
5353
return last_event_time;
5454
}
5555
virtual unsigned long getIntransactionPos()
5656
{
57-
boost::mutex::scoped_lock lock(m_mutex);
57+
std::lock_guard<std::mutex> lock(m_mutex);
5858
return intransaction_pos;
5959
}
6060
virtual void setMasterLogNamePos(const std::string& log_name, unsigned long pos)
6161
{
62-
boost::mutex::scoped_lock lock(m_mutex);
62+
std::lock_guard<std::mutex> lock(m_mutex);
6363
master_log_name = log_name; master_log_pos = pos;
6464
intransaction_pos = pos;
6565
}
6666
virtual unsigned long getMasterLogPos()
6767
{
68-
boost::mutex::scoped_lock lock(m_mutex);
68+
std::lock_guard<std::mutex> lock(m_mutex);
6969
return master_log_pos;
7070
}
7171
virtual std::string getMasterLogName()
7272
{
73-
boost::mutex::scoped_lock lock(m_mutex);
73+
std::lock_guard<std::mutex> lock(m_mutex);
7474
return master_log_name;
7575
}
7676
virtual void saveMasterInfo() {}
7777
virtual bool loadMasterInfo(std::string& logname, unsigned long& pos)
7878
{
79-
boost::mutex::scoped_lock lock(m_mutex);
79+
std::lock_guard<std::mutex> lock(m_mutex);
8080
logname.clear();
8181
pos = 0;
8282
return false;
8383
}
8484
virtual unsigned int getConnectCount()
8585
{
86-
boost::mutex::scoped_lock lock(m_mutex);
86+
std::lock_guard<std::mutex> lock(m_mutex);
8787
return connect_count;
8888
}
8989
virtual void setStateProcessing(bool _state)
9090
{
91-
boost::mutex::scoped_lock lock(m_mutex);
91+
std::lock_guard<std::mutex> lock(m_mutex);
9292
state_processing = _state;
9393
}
9494
virtual bool getStateProcessing()
9595
{
96-
boost::mutex::scoped_lock lock(m_mutex);
96+
std::lock_guard<std::mutex> lock(m_mutex);
9797
return state_processing;
9898
}
9999
virtual void initTableCount(const std::string& t) {}

Diff for: README.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@ For building the library, you will need:
3636
into your mysql include directory.
3737

3838
* The headers of the boost libraries (http://www.boost.org).
39-
At the minimum, you will need at least the shared_ptr.hpp, function.hpp,
40-
any.hpp and bind.hpp. If boost_unit_test_framework and boost_thread is
41-
found, tests will be built.
39+
At the minimum, you will need at least the any.hpp.
40+
If boost_unit_test_framework is found, tests will be built.
4241

4342
* You (likely) will need to review and edit the contents of Logging.h
4443
and SlaveStats.h

Diff for: Slave.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ void Slave::createTable(RelayLogInfo& rli,
149149
conn.query("SHOW FULL COLUMNS FROM " + tbl_name + " IN " + db_name);
150150
conn.store(res);
151151

152-
boost::shared_ptr<Table> table(new Table(db_name, tbl_name));
152+
std::shared_ptr<Table> table(new Table(db_name, tbl_name));
153153

154154

155155
LOG_DEBUG(log, "Created new Table object: database:" << db_name << " table: " << tbl_name );
@@ -392,7 +392,7 @@ struct raii_mysql_connector
392392
}// anonymous-namespace
393393

394394

395-
void Slave::get_remote_binlog( const boost::function< bool() >& _interruptFlag)
395+
void Slave::get_remote_binlog(const std::function<bool()>& _interruptFlag)
396396
{
397397
int count_packet = 0;
398398

Diff for: Slave.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#define __SLAVE_SLAVE_H_
2323

2424

25+
#include <functional>
2526
#include <string>
2627
#include <vector>
2728
#include <map>
@@ -64,7 +65,7 @@ class Slave
6465
callbacks_t m_callbacks;
6566
filters_t m_filters;
6667

67-
typedef boost::function<void (unsigned int)> xid_callback_t;
68+
typedef std::function<void (unsigned int)> xid_callback_t;
6869
xid_callback_t m_xid_callback;
6970

7071
RelayLogInfo m_rli;
@@ -112,7 +113,7 @@ class Slave
112113
m_xid_callback = _callback;
113114
}
114115

115-
void get_remote_binlog( const boost::function< bool() >& _interruptFlag = &Slave::falseFunction );
116+
void get_remote_binlog(const std::function<bool()>& _interruptFlag = &Slave::falseFunction);
116117

117118
void createDatabaseStructure() {
118119

Diff for: SlaveStats.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
*/
2828

2929

30-
#include <boost/shared_ptr.hpp>
30+
#include <memory>
3131
#include <string>
3232
#include <sys/time.h>
3333

@@ -179,7 +179,7 @@ struct EmptyExtState: public ExtStateIface {
179179
// Saves ExtStateIface or it's descendants.
180180
// Used in singleton.
181181
struct StateHolder {
182-
typedef boost::shared_ptr<ExtStateIface> PExtState;
182+
typedef std::shared_ptr<ExtStateIface> PExtState;
183183
PExtState ext_state;
184184
StateHolder() :
185185
ext_state(new EmptyExtState)

Diff for: nanomysql.h

-6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#ifndef __NANOMYSQL_H
1616
#define __NANOMYSQL_H
1717

18-
#include <boost/bind.hpp>
1918
#include <mysql/mysql.h>
2019
#include "nanofield.h"
2120
#include <stdexcept>
@@ -155,12 +154,7 @@ class Connection {
155154
typedef std::vector<fields_t> result_t;
156155

157156
void store(result_t& out) {
158-
#ifndef __GXX_EXPERIMENTAL_CXX0X__
159-
use(boost::bind(&result_t::push_back, &out, _1));
160-
#else
161157
use( [&out] (const std::map<std::string,field>& f) { out.push_back(f); } );
162-
#endif
163-
164158
}
165159
};
166160

Diff for: relayloginfo.h

+4-5
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,16 @@
1717

1818
#include "table.h"
1919

20-
#include <boost/shared_ptr.hpp>
21-
2220
#include <map>
21+
#include <memory>
2322
#include <string>
2423

2524

2625

2726
namespace slave {
2827

2928

30-
typedef boost::shared_ptr<Table> PtrTable;
29+
typedef std::shared_ptr<Table> PtrTable;
3130

3231
class RelayLogInfo {
3332

@@ -61,14 +60,14 @@ class RelayLogInfo {
6160
}
6261
}
6362

64-
boost::shared_ptr<Table> getTable(const std::pair<std::string, std::string>& key) {
63+
std::shared_ptr<Table> getTable(const std::pair<std::string, std::string>& key) {
6564
name_to_table_t::iterator p = m_table_map.find(key);
6665

6766
if (p != m_table_map.end()) {
6867
return p->second;
6968

7069
} else {
71-
return boost::shared_ptr<Table>();
70+
return std::shared_ptr<Table>();
7271
}
7372
}
7473

Diff for: slave_log_event.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ size_t n_set_bits(const std::vector<unsigned char>& b, unsigned int count) {
373373
}
374374

375375

376-
unsigned char* unpack_row(boost::shared_ptr<slave::Table> table,
376+
unsigned char* unpack_row(std::shared_ptr<slave::Table> table,
377377
slave::Row& _row,
378378
unsigned int colcnt,
379379
unsigned char* row,
@@ -442,7 +442,7 @@ unsigned char* unpack_row(boost::shared_ptr<slave::Table> table,
442442
}
443443

444444

445-
unsigned char* do_writedelete_row(boost::shared_ptr<slave::Table> table,
445+
unsigned char* do_writedelete_row(std::shared_ptr<slave::Table> table,
446446
const Basic_event_info& bei,
447447
const Row_event_info& roi,
448448
unsigned char* row_start,
@@ -467,7 +467,7 @@ unsigned char* do_writedelete_row(boost::shared_ptr<slave::Table> table,
467467
return t;
468468
}
469469

470-
unsigned char* do_update_row(boost::shared_ptr<slave::Table> table,
470+
unsigned char* do_update_row(std::shared_ptr<slave::Table> table,
471471
const Basic_event_info& bei,
472472
const Row_event_info& roi,
473473
unsigned char* row_start,
@@ -532,7 +532,7 @@ void apply_row_event(slave::RelayLogInfo& rli, const Basic_event_info& bei, cons
532532

533533
LOG_DEBUG(log, "applyRowEvent(): " << roi.m_table_id << " " << key.first << "." << key.second);
534534

535-
boost::shared_ptr<slave::Table> table = rli.getTable(key);
535+
std::shared_ptr<slave::Table> table = rli.getTable(key);
536536

537537
if (table) {
538538

Diff for: table.h

+4-5
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@
1616
#define __SLAVE_TABLE_H_
1717

1818

19+
#include <functional>
1920
#include <string>
2021
#include <vector>
2122
#include <map>
22-
23-
#include <boost/shared_ptr.hpp>
24-
#include <boost/function.hpp>
23+
#include <memory>
2524

2625
#include "field.h"
2726
#include "recordset.h"
@@ -31,8 +30,8 @@
3130
namespace slave
3231
{
3332

34-
typedef boost::shared_ptr<Field> PtrField;
35-
typedef boost::function<void (RecordSet&)> callback;
33+
typedef std::shared_ptr<Field> PtrField;
34+
typedef std::function<void (RecordSet&)> callback;
3635
typedef EventKind filter;
3736

3837

Diff for: test/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ TARGET_LINK_LIBRARIES (db_filler slave_a -lz -ldl -lpthread -lrt)
88

99
IF (Boost_FOUND)
1010
ADD_EXECUTABLE (unit_test unit_test.cpp)
11-
TARGET_LINK_LIBRARIES (unit_test slave_a ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} ${Boost_THREAD_LIBRARY} ${Boost_SYSTEM_LIBRARY} -lz -ldl -lpthread -lrt)
11+
TARGET_LINK_LIBRARIES (unit_test slave_a ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} ${Boost_SYSTEM_LIBRARY} -lz -ldl -lpthread -lrt)
1212
ADD_TEST (NAME unit_test COMMAND unit_test WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
1313
ENDIF (Boost_FOUND)

0 commit comments

Comments
 (0)