From: Mark Slee Date: Thu, 1 Feb 2007 22:55:30 +0000 (+0000) Subject: Bring C++ thrift stress test up to date with new constructs X-Git-Tag: 0.2.0~1506 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=739dbe55aee3baa81a3678fbb307b4e70d6caea8;p=common%2Fthrift.git Bring C++ thrift stress test up to date with new constructs Reviewed By: marc git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664966 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/test/cpp/Makefile.stress b/test/cpp/Makefile.stress index 804f5760..a0fe4cfc 100644 --- a/test/cpp/Makefile.stress +++ b/test/cpp/Makefile.stress @@ -25,7 +25,7 @@ include_flags = $(patsubst %,-I%, $(include_paths)) # Tools ifndef THRIFT -THRIFT = ../../compiler/cpp/bin/thrift +THRIFT = ../../compiler/cpp/thrift endif # THRIFT CC = g++ diff --git a/test/cpp/src/main.cpp b/test/cpp/src/main.cpp index 47da7970..266d6b67 100644 --- a/test/cpp/src/main.cpp +++ b/test/cpp/src/main.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -71,18 +72,18 @@ class Server : public ServiceIf { return counts_; } - int8_t echoByte(int8_t arg) {return arg;} - int32_t echoI32(int32_t arg) {return arg;} - int64_t echoI64(int64_t arg) {return arg;} - string echoString(string arg) { + int8_t echoByte(const int8_t arg) {return arg;} + int32_t echoI32(const int32_t arg) {return arg;} + int64_t echoI64(const int64_t arg) {return arg;} + void echoString(string& out, const string &arg) { if (arg != "hello") { T_ERROR_ABORT("WRONG STRING!!!!"); } - return arg; + out = arg; } - vector echoList(vector arg) {return arg;} - set echoSet(set arg) {return arg;} - map echoMap(map arg) {return arg;} + void echoList(vector &out, const vector &arg) { out = arg; } + void echoSet(set &out, const set &arg) { out = arg; } + void echoMap(map &out, const map &arg) { out = arg; } private: count_map counts_; @@ -179,7 +180,7 @@ public: for(size_t ix = 0; ix < _loopCount; ix++) { string arg = "hello"; string result; - result =_client->echoString(arg); + _client->echoString(result, arg); assert(result == arg); } } @@ -293,6 +294,8 @@ int main(int argc, char **argv) { } else if(serverType == "thread-pool") { + } else if(serverType == "threaded") { + } else { throw invalid_argument("Unknown server type "+serverType); @@ -364,6 +367,10 @@ int main(int argc, char **argv) { serverThread = threadFactory->newThread(shared_ptr(new TSimpleServer(serviceProcessor, serverSocket, transportFactory, protocolFactory))); + } else if (serverType == "threaded") { + + serverThread = threadFactory->newThread(shared_ptr(new TThreadedServer(serviceProcessor, serverSocket, transportFactory, protocolFactory))); + } else if(serverType == "thread-pool") { shared_ptr threadManager = ThreadManager::newSimpleThreadManager(workerCount); @@ -403,7 +410,7 @@ int main(int argc, char **argv) { shared_ptr socket(new TSocket("127.0.01", port)); shared_ptr bufferedSocket(new TBufferedTransport(socket, 2048)); - shared_ptr protocol(new TBinaryProtocol(bufferedSocket, bufferedSocket)); + shared_ptr protocol(new TBinaryProtocol(bufferedSocket)); shared_ptr serviceClient(new ServiceClient(protocol)); clientThreads.insert(threadFactory->newThread(shared_ptr(new ClientThread(socket, serviceClient, monitor, threadCount, loopCount, loopType))));