@@ -91,7 +91,7 @@ void TcpRemotingClient::stopAllTcpTransportThread() {
9191 m_threadpool.join_all ();
9292
9393 {
94- boost ::lock_guard<boost ::mutex> lock (m_futureTableLock);
94+ std ::lock_guard<std ::mutex> lock (m_futureTableLock);
9595 for (const auto & future : m_futureTable) {
9696 if (future.second )
9797 future.second ->releaseThreadCondition ();
@@ -108,9 +108,9 @@ void TcpRemotingClient::updateNameServerAddressList(const string& addrs) {
108108 return ;
109109 }
110110
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);
112112 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 ))) {
114114 LOG_ERROR (" updateNameServerAddressList get timed_mutex timeout" );
115115 return ;
116116 }
@@ -273,9 +273,9 @@ std::shared_ptr<TcpTransport> TcpRemotingClient::CreateTransport(const string& a
273273 {
274274 // try get m_tcpLock util m_tcpTransportTryLockTimeout to avoid blocking
275275 // 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);
277277 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))) {
279279 LOG_ERROR (" GetTransport of:%s get timed_mutex timeout" , addr.c_str ());
280280 std::shared_ptr<TcpTransport> pTcp;
281281 return pTcp;
@@ -338,9 +338,9 @@ std::shared_ptr<TcpTransport> TcpRemotingClient::CreateNameServerTransport(bool
338338 // try get m_tcpLock until m_tcpTransportTryLockTimeout to avoid blocking long
339339 // time, if could not get m_namesrvlock, return NULL
340340 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);
342342 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))) {
344344 LOG_ERROR (" CreateNameserverTransport get timed_mutex timeout" );
345345 std::shared_ptr<TcpTransport> pTcp;
346346 return pTcp;
@@ -375,9 +375,9 @@ bool TcpRemotingClient::CloseTransport(const string& addr, std::shared_ptr<TcpTr
375375 return CloseNameServerTransport (pTcp);
376376 }
377377
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);
379379 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))) {
381381 LOG_ERROR (" CloseTransport of:%s get timed_mutex timeout" , addr.c_str ());
382382 return false ;
383383 }
@@ -411,9 +411,9 @@ bool TcpRemotingClient::CloseTransport(const string& addr, std::shared_ptr<TcpTr
411411}
412412
413413bool 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);
415415 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))) {
417417 LOG_ERROR (" CreateNameServerTransport get timed_mutex timeout" );
418418 return false ;
419419 }
@@ -545,14 +545,14 @@ void TcpRemotingClient::processRequestCommand(RemotingCommand* pCmd, const strin
545545}
546546
547547void 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);
549549 m_futureTable[opaque] = pFuture;
550550}
551551
552552// Note: after call this function, shared_ptr of m_syncFutureTable[opaque] will
553553// be erased, so caller must ensure the life cycle of returned shared_ptr;
554554std::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);
556556 std::shared_ptr<ResponseFuture> pResponseFuture;
557557 if (m_futureTable.find (opaque) != m_futureTable.end ()) {
558558 pResponseFuture = m_futureTable[opaque];
@@ -562,14 +562,14 @@ std::shared_ptr<ResponseFuture> TcpRemotingClient::findAndDeleteResponseFuture(i
562562}
563563
564564void 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);
566566 m_asyncFutureTable[opaque] = pFuture;
567567}
568568
569569// Note: after call this function, shared_ptr of m_asyncFutureTable[opaque] will
570570// be erased, so caller must ensure the life cycle of returned shared_ptr;
571571std::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);
573573 std::shared_ptr<ResponseFuture> pResponseFuture;
574574 if (m_asyncFutureTable.find (opaque) != m_asyncFutureTable.end ()) {
575575 pResponseFuture = m_asyncFutureTable[opaque];
@@ -585,7 +585,7 @@ void TcpRemotingClient::registerProcessor(MQRequestCode requestCode, ClientRemot
585585}
586586
587587void 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);
589589 if (m_asyncTimerTable.find (opaque) != m_asyncTimerTable.end ()) {
590590 LOG_DEBUG (" addTimerCallback:erase timerCallback opaque:%lld" , opaque);
591591 boost::asio::deadline_timer* old_t = m_asyncTimerTable[opaque];
@@ -601,7 +601,7 @@ void TcpRemotingClient::addTimerCallback(boost::asio::deadline_timer* t, int opa
601601}
602602
603603void TcpRemotingClient::eraseTimerCallback (int opaque) {
604- boost ::lock_guard<boost ::mutex> lock (m_asyncTimerTableLock);
604+ std ::lock_guard<std ::mutex> lock (m_asyncTimerTableLock);
605605 if (m_asyncTimerTable.find (opaque) != m_asyncTimerTable.end ()) {
606606 LOG_DEBUG (" eraseTimerCallback: opaque:%lld" , opaque);
607607 boost::asio::deadline_timer* t = m_asyncTimerTable[opaque];
@@ -611,7 +611,7 @@ void TcpRemotingClient::eraseTimerCallback(int opaque) {
611611}
612612
613613void TcpRemotingClient::cancelTimerCallback (int opaque) {
614- boost ::lock_guard<boost ::mutex> lock (m_asyncTimerTableLock);
614+ std ::lock_guard<std ::mutex> lock (m_asyncTimerTableLock);
615615 if (m_asyncTimerTable.find (opaque) != m_asyncTimerTable.end ()) {
616616 LOG_DEBUG (" cancelTimerCallback: opaque:%lld" , opaque);
617617 boost::asio::deadline_timer* t = m_asyncTimerTable[opaque];
@@ -626,7 +626,7 @@ void TcpRemotingClient::cancelTimerCallback(int opaque) {
626626}
627627
628628void TcpRemotingClient::removeAllTimerCallback () {
629- boost ::lock_guard<boost ::mutex> lock (m_asyncTimerTableLock);
629+ std ::lock_guard<std ::mutex> lock (m_asyncTimerTableLock);
630630 for (const auto & timer : m_asyncTimerTable) {
631631 boost::asio::deadline_timer* t = timer.second ;
632632 try {
0 commit comments