@@ -91,7 +91,7 @@ void TcpRemotingClient::stopAllTcpTransportThread() {
91
91
m_threadpool.join_all ();
92
92
93
93
{
94
- boost ::lock_guard<boost ::mutex> lock (m_futureTableLock);
94
+ std ::lock_guard<std ::mutex> lock (m_futureTableLock);
95
95
for (const auto & future : m_futureTable) {
96
96
if (future.second )
97
97
future.second ->releaseThreadCondition ();
@@ -108,9 +108,9 @@ void TcpRemotingClient::updateNameServerAddressList(const string& addrs) {
108
108
return ;
109
109
}
110
110
111
- boost ::unique_lock<boost ::timed_mutex> lock (m_namesrvLock, boost ::try_to_lock);
111
+ std ::unique_lock<std ::timed_mutex> lock (m_namesrvLock, std ::try_to_lock);
112
112
if (!lock.owns_lock ()) {
113
- if (!lock.timed_lock ( boost::get_system_time () + boost::posix_time ::seconds (10 ))) {
113
+ if (!lock.try_lock_for ( std::chrono ::seconds (10 ))) {
114
114
LOG_ERROR (" updateNameServerAddressList get timed_mutex timeout" );
115
115
return ;
116
116
}
@@ -273,9 +273,9 @@ std::shared_ptr<TcpTransport> TcpRemotingClient::CreateTransport(const string& a
273
273
{
274
274
// try get m_tcpLock util m_tcpTransportTryLockTimeout to avoid blocking
275
275
// long time, if could not get m_tcpLock, return NULL
276
- boost ::unique_lock<boost ::timed_mutex> lock (m_tcpTableLock, boost ::try_to_lock);
276
+ std ::unique_lock<std ::timed_mutex> lock (m_tcpTableLock, std ::try_to_lock);
277
277
if (!lock.owns_lock ()) {
278
- if (!lock.timed_lock ( boost::get_system_time () + boost::posix_time ::seconds (m_tcpTransportTryLockTimeout))) {
278
+ if (!lock.try_lock_for ( std::chrono ::seconds (m_tcpTransportTryLockTimeout))) {
279
279
LOG_ERROR (" GetTransport of:%s get timed_mutex timeout" , addr.c_str ());
280
280
std::shared_ptr<TcpTransport> pTcp;
281
281
return pTcp;
@@ -338,9 +338,9 @@ std::shared_ptr<TcpTransport> TcpRemotingClient::CreateNameServerTransport(bool
338
338
// try get m_tcpLock until m_tcpTransportTryLockTimeout to avoid blocking long
339
339
// time, if could not get m_namesrvlock, return NULL
340
340
LOG_DEBUG (" --CreateNameserverTransport--" );
341
- boost ::unique_lock<boost ::timed_mutex> lock (m_namesrvLock, boost ::try_to_lock);
341
+ std ::unique_lock<std ::timed_mutex> lock (m_namesrvLock, std ::try_to_lock);
342
342
if (!lock.owns_lock ()) {
343
- if (!lock.timed_lock ( boost::get_system_time () + boost::posix_time ::seconds (m_tcpTransportTryLockTimeout))) {
343
+ if (!lock.try_lock_for ( std::chrono ::seconds (m_tcpTransportTryLockTimeout))) {
344
344
LOG_ERROR (" CreateNameserverTransport get timed_mutex timeout" );
345
345
std::shared_ptr<TcpTransport> pTcp;
346
346
return pTcp;
@@ -375,9 +375,9 @@ bool TcpRemotingClient::CloseTransport(const string& addr, std::shared_ptr<TcpTr
375
375
return CloseNameServerTransport (pTcp);
376
376
}
377
377
378
- boost ::unique_lock<boost ::timed_mutex> lock (m_tcpTableLock, boost ::try_to_lock);
378
+ std ::unique_lock<std ::timed_mutex> lock (m_tcpTableLock, std ::try_to_lock);
379
379
if (!lock.owns_lock ()) {
380
- if (!lock.timed_lock ( boost::get_system_time () + boost::posix_time ::seconds (m_tcpTransportTryLockTimeout))) {
380
+ if (!lock.try_lock_for ( std::chrono ::seconds (m_tcpTransportTryLockTimeout))) {
381
381
LOG_ERROR (" CloseTransport of:%s get timed_mutex timeout" , addr.c_str ());
382
382
return false ;
383
383
}
@@ -411,9 +411,9 @@ bool TcpRemotingClient::CloseTransport(const string& addr, std::shared_ptr<TcpTr
411
411
}
412
412
413
413
bool TcpRemotingClient::CloseNameServerTransport (std::shared_ptr<TcpTransport> pTcp) {
414
- boost ::unique_lock<boost ::timed_mutex> lock (m_namesrvLock, boost ::try_to_lock);
414
+ std ::unique_lock<std ::timed_mutex> lock (m_namesrvLock, std ::try_to_lock);
415
415
if (!lock.owns_lock ()) {
416
- if (!lock.timed_lock ( boost::get_system_time () + boost::posix_time ::seconds (m_tcpTransportTryLockTimeout))) {
416
+ if (!lock.try_lock_for ( std::chrono ::seconds (m_tcpTransportTryLockTimeout))) {
417
417
LOG_ERROR (" CreateNameServerTransport get timed_mutex timeout" );
418
418
return false ;
419
419
}
@@ -545,14 +545,14 @@ void TcpRemotingClient::processRequestCommand(RemotingCommand* pCmd, const strin
545
545
}
546
546
547
547
void TcpRemotingClient::addResponseFuture (int opaque, std::shared_ptr<ResponseFuture> pFuture) {
548
- boost ::lock_guard<boost ::mutex> lock (m_futureTableLock);
548
+ std ::lock_guard<std ::mutex> lock (m_futureTableLock);
549
549
m_futureTable[opaque] = pFuture;
550
550
}
551
551
552
552
// Note: after call this function, shared_ptr of m_syncFutureTable[opaque] will
553
553
// be erased, so caller must ensure the life cycle of returned shared_ptr;
554
554
std::shared_ptr<ResponseFuture> TcpRemotingClient::findAndDeleteResponseFuture (int opaque) {
555
- boost ::lock_guard<boost ::mutex> lock (m_futureTableLock);
555
+ std ::lock_guard<std ::mutex> lock (m_futureTableLock);
556
556
std::shared_ptr<ResponseFuture> pResponseFuture;
557
557
if (m_futureTable.find (opaque) != m_futureTable.end ()) {
558
558
pResponseFuture = m_futureTable[opaque];
@@ -562,14 +562,14 @@ std::shared_ptr<ResponseFuture> TcpRemotingClient::findAndDeleteResponseFuture(i
562
562
}
563
563
564
564
void TcpRemotingClient::addAsyncResponseFuture (int opaque, std::shared_ptr<ResponseFuture> pFuture) {
565
- boost ::lock_guard<boost ::mutex> lock (m_asyncFutureTableLock);
565
+ std ::lock_guard<std ::mutex> lock (m_asyncFutureTableLock);
566
566
m_asyncFutureTable[opaque] = pFuture;
567
567
}
568
568
569
569
// Note: after call this function, shared_ptr of m_asyncFutureTable[opaque] will
570
570
// be erased, so caller must ensure the life cycle of returned shared_ptr;
571
571
std::shared_ptr<ResponseFuture> TcpRemotingClient::findAndDeleteAsyncResponseFuture (int opaque) {
572
- boost ::lock_guard<boost ::mutex> lock (m_asyncFutureTableLock);
572
+ std ::lock_guard<std ::mutex> lock (m_asyncFutureTableLock);
573
573
std::shared_ptr<ResponseFuture> pResponseFuture;
574
574
if (m_asyncFutureTable.find (opaque) != m_asyncFutureTable.end ()) {
575
575
pResponseFuture = m_asyncFutureTable[opaque];
@@ -585,7 +585,7 @@ void TcpRemotingClient::registerProcessor(MQRequestCode requestCode, ClientRemot
585
585
}
586
586
587
587
void TcpRemotingClient::addTimerCallback (boost::asio::deadline_timer* t, int opaque) {
588
- boost ::lock_guard<boost ::mutex> lock (m_asyncTimerTableLock);
588
+ std ::lock_guard<std ::mutex> lock (m_asyncTimerTableLock);
589
589
if (m_asyncTimerTable.find (opaque) != m_asyncTimerTable.end ()) {
590
590
LOG_DEBUG (" addTimerCallback:erase timerCallback opaque:%lld" , opaque);
591
591
boost::asio::deadline_timer* old_t = m_asyncTimerTable[opaque];
@@ -601,7 +601,7 @@ void TcpRemotingClient::addTimerCallback(boost::asio::deadline_timer* t, int opa
601
601
}
602
602
603
603
void TcpRemotingClient::eraseTimerCallback (int opaque) {
604
- boost ::lock_guard<boost ::mutex> lock (m_asyncTimerTableLock);
604
+ std ::lock_guard<std ::mutex> lock (m_asyncTimerTableLock);
605
605
if (m_asyncTimerTable.find (opaque) != m_asyncTimerTable.end ()) {
606
606
LOG_DEBUG (" eraseTimerCallback: opaque:%lld" , opaque);
607
607
boost::asio::deadline_timer* t = m_asyncTimerTable[opaque];
@@ -611,7 +611,7 @@ void TcpRemotingClient::eraseTimerCallback(int opaque) {
611
611
}
612
612
613
613
void TcpRemotingClient::cancelTimerCallback (int opaque) {
614
- boost ::lock_guard<boost ::mutex> lock (m_asyncTimerTableLock);
614
+ std ::lock_guard<std ::mutex> lock (m_asyncTimerTableLock);
615
615
if (m_asyncTimerTable.find (opaque) != m_asyncTimerTable.end ()) {
616
616
LOG_DEBUG (" cancelTimerCallback: opaque:%lld" , opaque);
617
617
boost::asio::deadline_timer* t = m_asyncTimerTable[opaque];
@@ -626,7 +626,7 @@ void TcpRemotingClient::cancelTimerCallback(int opaque) {
626
626
}
627
627
628
628
void TcpRemotingClient::removeAllTimerCallback () {
629
- boost ::lock_guard<boost ::mutex> lock (m_asyncTimerTableLock);
629
+ std ::lock_guard<std ::mutex> lock (m_asyncTimerTableLock);
630
630
for (const auto & timer : m_asyncTimerTable) {
631
631
boost::asio::deadline_timer* t = timer.second ;
632
632
try {
0 commit comments