replace boost::atomic with std::atomic

This commit is contained in:
cyy 2019-01-06 10:05:50 +08:00 committed by James E. King III
parent e9421b826f
commit 7f8aef7099
3 changed files with 12 additions and 13 deletions

View File

@ -20,7 +20,7 @@
#ifndef _THRIFT_SERVER_TTHREADPOOLSERVER_H_
#define _THRIFT_SERVER_TTHREADPOOLSERVER_H_ 1
#include <boost/atomic.hpp>
#include <atomic>
#include <thrift/concurrency/ThreadManager.h>
#include <thrift/server/TServerFramework.h>
@ -90,8 +90,8 @@ protected:
virtual void onClientDisconnected(TConnectedClient* pClient) /* override */;
std::shared_ptr<apache::thrift::concurrency::ThreadManager> threadManager_;
boost::atomic<int64_t> timeout_;
boost::atomic<int64_t> taskExpiration_;
std::atomic<int64_t> timeout_;
std::atomic<int64_t> taskExpiration_;
};
}

View File

@ -24,11 +24,10 @@
#include <thrift/Thrift.h>
#include <thrift/TProcessor.h>
#include <atomic>
#include <string>
#include <stdio.h>
#include <boost/atomic.hpp>
#include <thrift/concurrency/Mutex.h>
#include <thrift/concurrency/Monitor.h>
#include <thrift/concurrency/PlatformThreadFactory.h>
@ -347,11 +346,11 @@ private:
// conditions used to block when the buffer is full or empty
Monitor notFull_, notEmpty_;
boost::atomic<bool> closing_;
std::atomic<bool> closing_;
// To keep track of whether the buffer has been flushed
Monitor flushed_;
boost::atomic<bool> forceFlush_;
std::atomic<bool> forceFlush_;
// Mutex that is grabbed when enqueueing and swapping the read/write buffers
Mutex mutex_;

View File

@ -18,8 +18,8 @@
*/
#define BOOST_TEST_MODULE TServerIntegrationTest
#include <atomic>
#include <boost/test/auto_unit_test.hpp>
#include <boost/atomic.hpp>
#include <boost/date_time/posix_time/ptime.hpp>
#include <boost/foreach.hpp>
#include <boost/format.hpp>
@ -310,10 +310,10 @@ public:
shared_ptr<TProtocol> pProtocol(new TBinaryProtocol(pSocket));
ParentServiceClient client(pProtocol);
pSocket->open();
bStressConnectionCount.fetch_add(1, boost::memory_order_relaxed);
bStressConnectionCount.fetch_add(1, std::memory_order_relaxed);
for (int i = 0; i < rand() % 1000; ++i) {
client.incrementGeneration();
bStressRequestCount.fetch_add(1, boost::memory_order_relaxed);
bStressRequestCount.fetch_add(1, std::memory_order_relaxed);
}
}
}
@ -321,9 +321,9 @@ public:
shared_ptr<TServerType> pServer;
shared_ptr<TServerReadyEventHandler> pEventHandler;
shared_ptr<boost::thread> pServerThread;
boost::atomic<bool> bStressDone;
boost::atomic_int64_t bStressConnectionCount;
boost::atomic_int64_t bStressRequestCount;
std::atomic<bool> bStressDone;
std::atomic<int64_t> bStressConnectionCount;
std::atomic<int64_t> bStressRequestCount;
};
template <class TServerType>