From: Roger Meier Date: Sun, 11 Dec 2011 22:08:51 +0000 (+0000) Subject: THRIFT-1459 declare shared_ptr as boost::shared_ptr X-Git-Tag: 0.9.1~494 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=611f90cf9ee177367d6b1f53d2ebb8493b44eec1;p=common%2Fthrift.git THRIFT-1459 declare shared_ptr as boost::shared_ptr git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1213090 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/lib/cpp/test/Benchmark.cpp b/lib/cpp/test/Benchmark.cpp old mode 100644 new mode 100755 index 36da0bd8..413802d2 --- a/lib/cpp/test/Benchmark.cpp +++ b/lib/cpp/test/Benchmark.cpp @@ -70,7 +70,7 @@ int main() { ooe.zomg_unicode = "\xd7\n\a\t"; ooe.base64 = "\1\2\3\255"; - shared_ptr buf(new TMemoryBuffer()); + boost::shared_ptr buf(new TMemoryBuffer()); int num = 1000000; @@ -96,7 +96,7 @@ int main() { for (int i = 0; i < num; i ++) { OneOfEach ooe2; - shared_ptr buf2(new TMemoryBuffer(data, datasize)); + boost::shared_ptr buf2(new TMemoryBuffer(data, datasize)); //buf2->resetBuffer(data, datasize); TBinaryProtocolT prot(buf2); ooe2.read(&prot); diff --git a/lib/cpp/test/RWMutexStarveTest.cpp b/lib/cpp/test/RWMutexStarveTest.cpp index ca04e6e2..8042d496 100644 --- a/lib/cpp/test/RWMutexStarveTest.cpp +++ b/lib/cpp/test/RWMutexStarveTest.cpp @@ -36,7 +36,7 @@ using namespace std; class Locker : public Runnable { protected: - Locker(shared_ptr rwlock, bool writer) : + Locker(boost::shared_ptr rwlock, bool writer) : rwlock_(rwlock), writer_(writer), started_(false), gotLock_(false), signaled_(false) { } @@ -61,7 +61,7 @@ public: void signal() { signaled_ = true; } protected: - shared_ptr rwlock_; + boost::shared_ptr rwlock_; bool writer_; volatile bool started_; volatile bool gotLock_; @@ -71,13 +71,13 @@ protected: class Reader : public Locker { public: - Reader(shared_ptr rwlock) : Locker(rwlock, false) { } + Reader(boost::shared_ptr rwlock) : Locker(rwlock, false) { } }; class Writer : public Locker { public: - Writer(shared_ptr rwlock) : Locker(rwlock, true) { } + Writer(boost::shared_ptr rwlock) : Locker(rwlock, true) { } }; void test_starve(PosixThreadFactory::POLICY policy) @@ -88,15 +88,15 @@ void test_starve(PosixThreadFactory::POLICY policy) PosixThreadFactory factory(policy); factory.setDetached(false); - shared_ptr rwlock(new NoStarveReadWriteMutex()); + boost::shared_ptr rwlock(new NoStarveReadWriteMutex()); - shared_ptr reader1(new Reader(rwlock)); - shared_ptr reader2(new Reader(rwlock)); - shared_ptr writer(new Writer(rwlock)); + boost::shared_ptr reader1(new Reader(rwlock)); + boost::shared_ptr reader2(new Reader(rwlock)); + boost::shared_ptr writer(new Writer(rwlock)); - shared_ptr treader1 = factory.newThread(reader1); - shared_ptr treader2 = factory.newThread(reader2); - shared_ptr twriter = factory.newThread(writer); + boost::shared_ptr treader1 = factory.newThread(reader1); + boost::shared_ptr treader2 = factory.newThread(reader2); + boost::shared_ptr twriter = factory.newThread(writer); // launch a reader and make sure he has the lock treader1->start(); diff --git a/lib/cpp/test/TPipedTransportTest.cpp b/lib/cpp/test/TPipedTransportTest.cpp index 5708fd21..e1e372c3 100644 --- a/lib/cpp/test/TPipedTransportTest.cpp +++ b/lib/cpp/test/TPipedTransportTest.cpp @@ -23,15 +23,14 @@ #include #include using namespace std; -using boost::shared_ptr; using apache::thrift::transport::TTransportException; using apache::thrift::transport::TPipedTransport; using apache::thrift::transport::TMemoryBuffer; int main() { - shared_ptr underlying(new TMemoryBuffer); - shared_ptr pipe(new TMemoryBuffer); - shared_ptr trans(new TPipedTransport(underlying, pipe)); + boost::shared_ptr underlying(new TMemoryBuffer); + boost::shared_ptr pipe(new TMemoryBuffer); + boost::shared_ptr trans(new TPipedTransport(underlying, pipe)); uint8_t buffer[4]; diff --git a/lib/cpp/test/ZlibTest.cpp b/lib/cpp/test/ZlibTest.cpp index 9df9dc4e..605e9db0 100644 --- a/lib/cpp/test/ZlibTest.cpp +++ b/lib/cpp/test/ZlibTest.cpp @@ -142,8 +142,8 @@ uint8_t* gen_random_buffer(uint32_t buf_len) { */ void test_write_then_read(const uint8_t* buf, uint32_t buf_len) { - shared_ptr membuf(new TMemoryBuffer()); - shared_ptr zlib_trans(new TZlibTransport(membuf)); + boost::shared_ptr membuf(new TMemoryBuffer()); + boost::shared_ptr zlib_trans(new TZlibTransport(membuf)); zlib_trans->write(buf, buf_len); zlib_trans->finish(); @@ -161,8 +161,8 @@ void test_separate_checksum(const uint8_t* buf, uint32_t buf_len) { // it isn't there. The original implementation complained that // the stream was not complete. I'm about to go fix that. // It worked. Awesome. - shared_ptr membuf(new TMemoryBuffer()); - shared_ptr zlib_trans(new TZlibTransport(membuf)); + boost::shared_ptr membuf(new TMemoryBuffer()); + boost::shared_ptr zlib_trans(new TZlibTransport(membuf)); zlib_trans->write(buf, buf_len); zlib_trans->finish(); string tmp_buf; @@ -181,8 +181,8 @@ void test_separate_checksum(const uint8_t* buf, uint32_t buf_len) { void test_incomplete_checksum(const uint8_t* buf, uint32_t buf_len) { // Make sure we still get that "not complete" error if // it really isn't complete. - shared_ptr membuf(new TMemoryBuffer()); - shared_ptr zlib_trans(new TZlibTransport(membuf)); + boost::shared_ptr membuf(new TMemoryBuffer()); + boost::shared_ptr zlib_trans(new TZlibTransport(membuf)); zlib_trans->write(buf, buf_len); zlib_trans->finish(); string tmp_buf; @@ -205,11 +205,11 @@ void test_incomplete_checksum(const uint8_t* buf, uint32_t buf_len) { } void test_read_write_mix(const uint8_t* buf, uint32_t buf_len, - const shared_ptr& write_gen, - const shared_ptr& read_gen) { + const boost::shared_ptr& write_gen, + const boost::shared_ptr& read_gen) { // Try it with a mix of read/write sizes. - shared_ptr membuf(new TMemoryBuffer()); - shared_ptr zlib_trans(new TZlibTransport(membuf)); + boost::shared_ptr membuf(new TMemoryBuffer()); + boost::shared_ptr zlib_trans(new TZlibTransport(membuf)); unsigned int tot; tot = 0; @@ -244,8 +244,8 @@ void test_read_write_mix(const uint8_t* buf, uint32_t buf_len, void test_invalid_checksum(const uint8_t* buf, uint32_t buf_len) { // Verify checksum checking. - shared_ptr membuf(new TMemoryBuffer()); - shared_ptr zlib_trans(new TZlibTransport(membuf)); + boost::shared_ptr membuf(new TMemoryBuffer()); + boost::shared_ptr zlib_trans(new TZlibTransport(membuf)); zlib_trans->write(buf, buf_len); zlib_trans->finish(); string tmp_buf; @@ -282,8 +282,8 @@ void test_invalid_checksum(const uint8_t* buf, uint32_t buf_len) { void test_write_after_flush(const uint8_t* buf, uint32_t buf_len) { // write some data - shared_ptr membuf(new TMemoryBuffer()); - shared_ptr zlib_trans(new TZlibTransport(membuf)); + boost::shared_ptr membuf(new TMemoryBuffer()); + boost::shared_ptr zlib_trans(new TZlibTransport(membuf)); zlib_trans->write(buf, buf_len); // call finish() @@ -318,7 +318,7 @@ void test_write_after_flush(const uint8_t* buf, uint32_t buf_len) { void test_no_write() { // Verify that no data is written to the underlying transport if we // never write data to the TZlibTransport. - shared_ptr membuf(new TMemoryBuffer()); + boost::shared_ptr membuf(new TMemoryBuffer()); { // Create a TZlibTransport object, and immediately destroy it // when it goes out of scope. @@ -352,8 +352,8 @@ void add_tests(unit_test::test_suite* suite, ADD_TEST_CASE(suite, name, test_invalid_checksum, buf, buf_len); ADD_TEST_CASE(suite, name, test_write_after_flush, buf, buf_len); - shared_ptr size_32k(new ConstantSizeGenerator(1<<15)); - shared_ptr size_lognormal(new LogNormalSizeGenerator(20, 30)); + boost::shared_ptr size_32k(new ConstantSizeGenerator(1<<15)); + boost::shared_ptr size_lognormal(new LogNormalSizeGenerator(20, 30)); ADD_TEST_CASE(suite, name << "-constant", test_read_write_mix, buf, buf_len, size_32k, size_32k); @@ -373,8 +373,8 @@ void add_tests(unit_test::test_suite* suite, // Because the SizeGenerator makes a copy of the random number generator, // both SizeGenerators should return the exact same set of values, since they // both start with random number generators in the same state. - shared_ptr write_size_gen(new LogNormalSizeGenerator(20, 30)); - shared_ptr read_size_gen(new LogNormalSizeGenerator(20, 30)); + boost::shared_ptr write_size_gen(new LogNormalSizeGenerator(20, 30)); + boost::shared_ptr read_size_gen(new LogNormalSizeGenerator(20, 30)); ADD_TEST_CASE(suite, name << "-lognormal-same-distribution", test_read_write_mix, buf, buf_len, write_size_gen, read_size_gen); diff --git a/test/cpp/src/StressTest.cpp b/test/cpp/src/StressTest.cpp index 339e7d13..a668fdf3 100755 --- a/test/cpp/src/StressTest.cpp +++ b/test/cpp/src/StressTest.cpp @@ -109,7 +109,7 @@ private: class ClientThread: public Runnable { public: - ClientThread(shared_ptrtransport, shared_ptr client, Monitor& monitor, size_t& workerCount, size_t loopCount, TType loopType) : + ClientThread(boost::shared_ptrtransport, boost::shared_ptr client, Monitor& monitor, size_t& workerCount, size_t loopCount, TType loopType) : _transport(transport), _client(client), _monitor(monitor), @@ -200,8 +200,8 @@ public: } } - shared_ptr _transport; - shared_ptr _client; + boost::shared_ptr _transport; + boost::shared_ptr _client; Monitor& _monitor; size_t& _workerCount; size_t _loopCount; @@ -326,23 +326,23 @@ int main(int argc, char **argv) { cerr << usage; } - shared_ptr threadFactory = shared_ptr(new PlatformThreadFactory()); + boost::shared_ptr threadFactory = boost::shared_ptr(new PlatformThreadFactory()); // Dispatcher - shared_ptr serviceHandler(new Server()); + boost::shared_ptr serviceHandler(new Server()); if (replayRequests) { - shared_ptr serviceHandler(new Server()); - shared_ptr serviceProcessor(new ServiceProcessor(serviceHandler)); + boost::shared_ptr serviceHandler(new Server()); + boost::shared_ptr serviceProcessor(new ServiceProcessor(serviceHandler)); // Transports - shared_ptr fileTransport(new TFileTransport(requestLogPath)); + boost::shared_ptr fileTransport(new TFileTransport(requestLogPath)); fileTransport->setChunkSize(2 * 1024 * 1024); fileTransport->setMaxEventSize(1024 * 16); fileTransport->seekToEnd(); // Protocol Factory - shared_ptr protocolFactory(new TBinaryProtocolFactory()); + boost::shared_ptr protocolFactory(new TBinaryProtocolFactory()); TFileProcessor fileProcessor(serviceProcessor, protocolFactory, @@ -355,44 +355,44 @@ int main(int argc, char **argv) { if (runServer) { - shared_ptr serviceProcessor(new ServiceProcessor(serviceHandler)); + boost::shared_ptr serviceProcessor(new ServiceProcessor(serviceHandler)); // Transport - shared_ptr serverSocket(new TServerSocket(port)); + boost::shared_ptr serverSocket(new TServerSocket(port)); // Transport Factory - shared_ptr transportFactory(new TBufferedTransportFactory()); + boost::shared_ptr transportFactory(new TBufferedTransportFactory()); // Protocol Factory - shared_ptr protocolFactory(new TBinaryProtocolFactory()); + boost::shared_ptr protocolFactory(new TBinaryProtocolFactory()); if (logRequests) { // initialize the log file - shared_ptr fileTransport(new TFileTransport(requestLogPath)); + boost::shared_ptr fileTransport(new TFileTransport(requestLogPath)); fileTransport->setChunkSize(2 * 1024 * 1024); fileTransport->setMaxEventSize(1024 * 16); transportFactory = - shared_ptr(new TPipedTransportFactory(fileTransport)); + boost::shared_ptr(new TPipedTransportFactory(fileTransport)); } - shared_ptr serverThread; + boost::shared_ptr serverThread; if (serverType == "simple") { - serverThread = threadFactory->newThread(shared_ptr(new TSimpleServer(serviceProcessor, serverSocket, transportFactory, protocolFactory))); + serverThread = threadFactory->newThread(boost::shared_ptr(new TSimpleServer(serviceProcessor, serverSocket, transportFactory, protocolFactory))); } else if (serverType == "threaded") { - serverThread = threadFactory->newThread(shared_ptr(new TThreadedServer(serviceProcessor, serverSocket, transportFactory, protocolFactory))); + serverThread = threadFactory->newThread(boost::shared_ptr(new TThreadedServer(serviceProcessor, serverSocket, transportFactory, protocolFactory))); } else if (serverType == "thread-pool") { - shared_ptr threadManager = ThreadManager::newSimpleThreadManager(workerCount); + boost::shared_ptr threadManager = ThreadManager::newSimpleThreadManager(workerCount); threadManager->threadFactory(threadFactory); threadManager->start(); - serverThread = threadFactory->newThread(shared_ptr(new TThreadPoolServer(serviceProcessor, serverSocket, transportFactory, protocolFactory, threadManager))); + serverThread = threadFactory->newThread(boost::shared_ptr(new TThreadPoolServer(serviceProcessor, serverSocket, transportFactory, protocolFactory, threadManager))); } cerr << "Starting the server on port " << port << endl; @@ -412,7 +412,7 @@ int main(int argc, char **argv) { size_t threadCount = 0; - set > clientThreads; + set > clientThreads; if (callName == "echoVoid") { loopType = T_VOID;} else if (callName == "echoByte") { loopType = T_BYTE;} @@ -423,15 +423,15 @@ int main(int argc, char **argv) { for (size_t ix = 0; ix < clientCount; ix++) { - shared_ptr socket(new TSocket("127.0.0.1", port)); - shared_ptr bufferedSocket(new TBufferedTransport(socket, 2048)); - shared_ptr protocol(new TBinaryProtocol(bufferedSocket)); - shared_ptr serviceClient(new ServiceClient(protocol)); + boost::shared_ptr socket(new TSocket("127.0.0.1", port)); + boost::shared_ptr bufferedSocket(new TBufferedTransport(socket, 2048)); + boost::shared_ptr protocol(new TBinaryProtocol(bufferedSocket)); + boost::shared_ptr serviceClient(new ServiceClient(protocol)); - clientThreads.insert(threadFactory->newThread(shared_ptr(new ClientThread(socket, serviceClient, monitor, threadCount, loopCount, loopType)))); + clientThreads.insert(threadFactory->newThread(boost::shared_ptr(new ClientThread(socket, serviceClient, monitor, threadCount, loopCount, loopType)))); } - for (std::set >::const_iterator thread = clientThreads.begin(); thread != clientThreads.end(); thread++) { + for (std::set >::const_iterator thread = clientThreads.begin(); thread != clientThreads.end(); thread++) { (*thread)->start(); } @@ -461,9 +461,9 @@ int main(int argc, char **argv) { int64_t minTime = 9223372036854775807LL; int64_t maxTime = 0; - for (set >::iterator ix = clientThreads.begin(); ix != clientThreads.end(); ix++) { + for (set >::iterator ix = clientThreads.begin(); ix != clientThreads.end(); ix++) { - shared_ptr client = dynamic_pointer_cast((*ix)->runnable()); + boost::shared_ptr client = dynamic_pointer_cast((*ix)->runnable()); int64_t delta = client->_endTime - client->_startTime; diff --git a/test/cpp/src/StressTestNonBlocking.cpp b/test/cpp/src/StressTestNonBlocking.cpp index 2ff507b7..4826a509 100755 --- a/test/cpp/src/StressTestNonBlocking.cpp +++ b/test/cpp/src/StressTestNonBlocking.cpp @@ -115,7 +115,7 @@ private: class ClientThread: public Runnable { public: - ClientThread(shared_ptrtransport, shared_ptr client, Monitor& monitor, size_t& workerCount, size_t loopCount, TType loopType) : + ClientThread(boost::shared_ptrtransport, boost::shared_ptr client, Monitor& monitor, size_t& workerCount, size_t loopCount, TType loopType) : _transport(transport), _client(client), _monitor(monitor), @@ -206,8 +206,8 @@ public: } } - shared_ptr _transport; - shared_ptr _client; + boost::shared_ptr _transport; + boost::shared_ptr _client; Monitor& _monitor; size_t& _workerCount; size_t _loopCount; @@ -321,23 +321,23 @@ int main(int argc, char **argv) { cerr << usage; } - shared_ptr threadFactory = shared_ptr(new PlatformThreadFactory()); + boost::shared_ptr threadFactory = boost::shared_ptr(new PlatformThreadFactory()); // Dispatcher - shared_ptr serviceHandler(new Server()); + boost::shared_ptr serviceHandler(new Server()); if (replayRequests) { - shared_ptr serviceHandler(new Server()); - shared_ptr serviceProcessor(new ServiceProcessor(serviceHandler)); + boost::shared_ptr serviceHandler(new Server()); + boost::shared_ptr serviceProcessor(new ServiceProcessor(serviceHandler)); // Transports - shared_ptr fileTransport(new TFileTransport(requestLogPath)); + boost::shared_ptr fileTransport(new TFileTransport(requestLogPath)); fileTransport->setChunkSize(2 * 1024 * 1024); fileTransport->setMaxEventSize(1024 * 16); fileTransport->seekToEnd(); // Protocol Factory - shared_ptr protocolFactory(new TBinaryProtocolFactory()); + boost::shared_ptr protocolFactory(new TBinaryProtocolFactory()); TFileProcessor fileProcessor(serviceProcessor, protocolFactory, @@ -350,40 +350,40 @@ int main(int argc, char **argv) { if (runServer) { - shared_ptr serviceProcessor(new ServiceProcessor(serviceHandler)); + boost::shared_ptr serviceProcessor(new ServiceProcessor(serviceHandler)); // Protocol Factory - shared_ptr protocolFactory(new TBinaryProtocolFactory()); + boost::shared_ptr protocolFactory(new TBinaryProtocolFactory()); // Transport Factory - shared_ptr transportFactory; + boost::shared_ptr transportFactory; if (logRequests) { // initialize the log file - shared_ptr fileTransport(new TFileTransport(requestLogPath)); + boost::shared_ptr fileTransport(new TFileTransport(requestLogPath)); fileTransport->setChunkSize(2 * 1024 * 1024); fileTransport->setMaxEventSize(1024 * 16); transportFactory = - shared_ptr(new TPipedTransportFactory(fileTransport)); + boost::shared_ptr(new TPipedTransportFactory(fileTransport)); } - shared_ptr serverThread; - shared_ptr serverThread2; + boost::shared_ptr serverThread; + boost::shared_ptr serverThread2; if (serverType == "simple") { - serverThread = threadFactory->newThread(shared_ptr(new TNonblockingServer(serviceProcessor, protocolFactory, port))); - serverThread2 = threadFactory->newThread(shared_ptr(new TNonblockingServer(serviceProcessor, protocolFactory, port+1))); + serverThread = threadFactory->newThread(boost::shared_ptr(new TNonblockingServer(serviceProcessor, protocolFactory, port))); + serverThread2 = threadFactory->newThread(boost::shared_ptr(new TNonblockingServer(serviceProcessor, protocolFactory, port+1))); } else if (serverType == "thread-pool") { - shared_ptr threadManager = ThreadManager::newSimpleThreadManager(workerCount); + boost::shared_ptr threadManager = ThreadManager::newSimpleThreadManager(workerCount); threadManager->threadFactory(threadFactory); threadManager->start(); - serverThread = threadFactory->newThread(shared_ptr(new TNonblockingServer(serviceProcessor, protocolFactory, port, threadManager))); - serverThread2 = threadFactory->newThread(shared_ptr(new TNonblockingServer(serviceProcessor, protocolFactory, port+1, threadManager))); + serverThread = threadFactory->newThread(boost::shared_ptr(new TNonblockingServer(serviceProcessor, protocolFactory, port, threadManager))); + serverThread2 = threadFactory->newThread(boost::shared_ptr(new TNonblockingServer(serviceProcessor, protocolFactory, port+1, threadManager))); } cerr << "Starting the server on port " << port << " and " << (port + 1) << endl; @@ -405,7 +405,7 @@ int main(int argc, char **argv) { size_t threadCount = 0; - set > clientThreads; + set > clientThreads; if (callName == "echoVoid") { loopType = T_VOID;} else if (callName == "echoByte") { loopType = T_BYTE;} @@ -416,15 +416,15 @@ int main(int argc, char **argv) { for (size_t ix = 0; ix < clientCount; ix++) { - shared_ptr socket(new TSocket("127.0.0.1", port + (ix % 2))); - shared_ptr framedSocket(new TFramedTransport(socket)); - shared_ptr protocol(new TBinaryProtocol(framedSocket)); - shared_ptr serviceClient(new ServiceClient(protocol)); + boost::shared_ptr socket(new TSocket("127.0.0.1", port + (ix % 2))); + boost::shared_ptr framedSocket(new TFramedTransport(socket)); + boost::shared_ptr protocol(new TBinaryProtocol(framedSocket)); + boost::shared_ptr serviceClient(new ServiceClient(protocol)); - clientThreads.insert(threadFactory->newThread(shared_ptr(new ClientThread(socket, serviceClient, monitor, threadCount, loopCount, loopType)))); + clientThreads.insert(threadFactory->newThread(boost::shared_ptr(new ClientThread(socket, serviceClient, monitor, threadCount, loopCount, loopType)))); } - for (std::set >::const_iterator thread = clientThreads.begin(); thread != clientThreads.end(); thread++) { + for (std::set >::const_iterator thread = clientThreads.begin(); thread != clientThreads.end(); thread++) { (*thread)->start(); } @@ -454,9 +454,9 @@ int main(int argc, char **argv) { int64_t minTime = 9223372036854775807LL; int64_t maxTime = 0; - for (set >::iterator ix = clientThreads.begin(); ix != clientThreads.end(); ix++) { + for (set >::iterator ix = clientThreads.begin(); ix != clientThreads.end(); ix++) { - shared_ptr client = dynamic_pointer_cast((*ix)->runnable()); + boost::shared_ptr client = dynamic_pointer_cast((*ix)->runnable()); int64_t delta = client->_endTime - client->_startTime; diff --git a/test/cpp/src/TestClient.cpp b/test/cpp/src/TestClient.cpp index ed560cb5..e752f1c9 100755 --- a/test/cpp/src/TestClient.cpp +++ b/test/cpp/src/TestClient.cpp @@ -82,7 +82,7 @@ static void testVoid_clientReturn(const char* host, int port, event_base *base, // next test delete client; - shared_ptr channel(new TEvhttpClientChannel(host, "/", host, port, base)); + boost::shared_ptr channel(new TEvhttpClientChannel(host, "/", host, port, base)); client = new ThriftTestCobClient(channel, protocolFactory); client->testString(tr1::bind(testString_clientReturn, host, port, base, protocolFactory, std::tr1::placeholders::_1), "Test"); } catch (TException& exn) { @@ -149,44 +149,44 @@ int main(int argc, char** argv) { ssl = true; } - shared_ptr transport; - shared_ptr protocol; + boost::shared_ptr transport; + boost::shared_ptr protocol; - shared_ptr socket; - shared_ptr factory; + boost::shared_ptr socket; + boost::shared_ptr factory; if (ssl) { - factory = shared_ptr(new TSSLSocketFactory()); + factory = boost::shared_ptr(new TSSLSocketFactory()); factory->ciphers("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH"); factory->loadTrustedCertificates("./trusted-ca-certificate.pem"); factory->authenticate(true); socket = factory->createSocket(host, port); } else { if (domain_socket != "") { - socket = shared_ptr(new TSocket(domain_socket)); + socket = boost::shared_ptr(new TSocket(domain_socket)); port = 0; } else { - socket = shared_ptr(new TSocket(host, port)); + socket = boost::shared_ptr(new TSocket(host, port)); } } if (transport_type.compare("http") == 0) { - shared_ptr httpSocket(new THttpClient(socket, host, "/service")); + boost::shared_ptr httpSocket(new THttpClient(socket, host, "/service")); transport = httpSocket; } else if (transport_type.compare("framed") == 0){ - shared_ptr framedSocket(new TFramedTransport(socket)); + boost::shared_ptr framedSocket(new TFramedTransport(socket)); transport = framedSocket; } else{ - shared_ptr bufferedSocket(new TBufferedTransport(socket)); + boost::shared_ptr bufferedSocket(new TBufferedTransport(socket)); transport = bufferedSocket; } if (protocol_type.compare("json") == 0) { - shared_ptr jsonProtocol(new TJSONProtocol(transport)); + boost::shared_ptr jsonProtocol(new TJSONProtocol(transport)); protocol = jsonProtocol; } else{ - shared_ptr binaryProtocol(new TBinaryProtocol(transport)); + boost::shared_ptr binaryProtocol(new TBinaryProtocol(transport)); protocol = binaryProtocol; } @@ -205,9 +205,9 @@ int main(int argc, char** argv) { cout << "Libevent Features: 0x" << hex << event_base_get_features(base) << endl; #endif - shared_ptr protocolFactory(new TBinaryProtocolFactory()); + boost::shared_ptr protocolFactory(new TBinaryProtocolFactory()); - shared_ptr channel(new TEvhttpClientChannel(host.c_str(), "/", host.c_str(), port, base)); + boost::shared_ptr channel(new TEvhttpClientChannel(host.c_str(), "/", host.c_str(), port, base)); ThriftTestCobClient* client = new ThriftTestCobClient(channel, protocolFactory.get()); client->testVoid(tr1::bind(testVoid_clientReturn, host.c_str(), port, base, protocolFactory.get(), std::tr1::placeholders::_1)); diff --git a/test/cpp/src/TestServer.cpp b/test/cpp/src/TestServer.cpp index 456577f8..b8cb8804 100755 --- a/test/cpp/src/TestServer.cpp +++ b/test/cpp/src/TestServer.cpp @@ -360,7 +360,7 @@ class TestProcessorEventHandler : public TProcessorEventHandler { class TestHandlerAsync : public ThriftTestCobSvIf { public: - TestHandlerAsync(shared_ptr& handler) : _delegate(handler) {} + TestHandlerAsync(boost::shared_ptr& handler) : _delegate(handler) {} virtual ~TestHandlerAsync() {} virtual void testVoid(std::tr1::function cob) { @@ -485,7 +485,7 @@ public: } protected: - shared_ptr _delegate; + boost::shared_ptr _delegate; }; @@ -566,56 +566,56 @@ int main(int argc, char **argv) { } // Dispatcher - shared_ptr protocolFactory; + boost::shared_ptr protocolFactory; if (protocol_type == "json") { - shared_ptr jsonProtocolFactory(new TJSONProtocolFactory()); + boost::shared_ptr jsonProtocolFactory(new TJSONProtocolFactory()); protocolFactory = jsonProtocolFactory; } else { - shared_ptr binaryProtocolFactory(new TBinaryProtocolFactoryT()); + boost::shared_ptr binaryProtocolFactory(new TBinaryProtocolFactoryT()); protocolFactory = binaryProtocolFactory; } // Processor - shared_ptr testHandler(new TestHandler()); - shared_ptr testProcessor(new ThriftTestProcessor(testHandler)); + boost::shared_ptr testHandler(new TestHandler()); + boost::shared_ptr testProcessor(new ThriftTestProcessor(testHandler)); if (vm.count("processor-events")) { - testProcessor->setEventHandler(shared_ptr( + testProcessor->setEventHandler(boost::shared_ptr( new TestProcessorEventHandler())); } // Transport - shared_ptr sslSocketFactory; - shared_ptr serverSocket; + boost::shared_ptr sslSocketFactory; + boost::shared_ptr serverSocket; if (ssl) { - sslSocketFactory = shared_ptr(new TSSLSocketFactory()); + sslSocketFactory = boost::shared_ptr(new TSSLSocketFactory()); sslSocketFactory->loadCertificate("./server-certificate.pem"); sslSocketFactory->loadPrivateKey("./server-private-key.pem"); sslSocketFactory->ciphers("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH"); - serverSocket = shared_ptr(new TSSLServerSocket(port, sslSocketFactory)); + serverSocket = boost::shared_ptr(new TSSLServerSocket(port, sslSocketFactory)); } else { if (domain_socket != "") { unlink(domain_socket.c_str()); - serverSocket = shared_ptr(new TServerSocket(domain_socket)); + serverSocket = boost::shared_ptr(new TServerSocket(domain_socket)); port = 0; } else { - serverSocket = shared_ptr(new TServerSocket(port)); + serverSocket = boost::shared_ptr(new TServerSocket(port)); } } // Factory - shared_ptr transportFactory; + boost::shared_ptr transportFactory; if (transport_type == "http" && server_type != "nonblocking") { - shared_ptr httpTransportFactory(new THttpServerTransportFactory()); + boost::shared_ptr httpTransportFactory(new THttpServerTransportFactory()); transportFactory = httpTransportFactory; } else if (transport_type == "framed") { - shared_ptr framedTransportFactory(new TFramedTransportFactory()); + boost::shared_ptr framedTransportFactory(new TFramedTransportFactory()); transportFactory = framedTransportFactory; } else { - shared_ptr bufferedTransportFactory(new TBufferedTransportFactory()); + boost::shared_ptr bufferedTransportFactory(new TBufferedTransportFactory()); transportFactory = bufferedTransportFactory; } @@ -638,11 +638,11 @@ int main(int argc, char **argv) { } else if (server_type == "thread-pool") { - shared_ptr threadManager = + boost::shared_ptr threadManager = ThreadManager::newSimpleThreadManager(workers); - shared_ptr threadFactory = - shared_ptr(new PlatformThreadFactory()); + boost::shared_ptr threadFactory = + boost::shared_ptr(new PlatformThreadFactory()); threadManager->threadFactory(threadFactory); @@ -667,9 +667,9 @@ int main(int argc, char **argv) { } else if (server_type == "nonblocking") { if(transport_type == "http") { - shared_ptr testHandlerAsync(new TestHandlerAsync(testHandler)); - shared_ptr testProcessorAsync(new ThriftTestAsyncProcessor(testHandlerAsync)); - shared_ptr testBufferProcessor(new TAsyncProtocolProcessor(testProcessorAsync, protocolFactory)); + boost::shared_ptr testHandlerAsync(new TestHandlerAsync(testHandler)); + boost::shared_ptr testProcessorAsync(new ThriftTestAsyncProcessor(testHandlerAsync)); + boost::shared_ptr testBufferProcessor(new TAsyncProtocolProcessor(testProcessorAsync, protocolFactory)); TEvhttpServer nonblockingServer(testBufferProcessor, port); nonblockingServer.serve();