summaryrefslogtreecommitdiff
path: root/test/threads
diff options
context:
space:
mode:
authorMark Slee <mcslee@apache.org>2007-03-05 05:40:37 +0000
committerMark Slee <mcslee@apache.org>2007-03-05 05:40:37 +0000
commitc416a2730da7979933133c825dd576fee075436a (patch)
tree4969f165d92a9d15446fd461eb8bf9472d7c2b2f /test/threads
parentb32f3c6ad76536e6a8e334064fb09f8c6ddebb9e (diff)
downloadthrift-c416a2730da7979933133c825dd576fee075436a.tar.gz
Threads testing package update
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665042 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test/threads')
-rw-r--r--test/threads/Makefile5
-rw-r--r--test/threads/ThreadsClient.cpp43
-rw-r--r--test/threads/ThreadsServer.cpp15
-rwxr-xr-xtest/threads/ThreadsTest.thrift10
4 files changed, 62 insertions, 11 deletions
diff --git a/test/threads/Makefile b/test/threads/Makefile
index 79c0134c4..7e8894430 100644
--- a/test/threads/Makefile
+++ b/test/threads/Makefile
@@ -34,7 +34,7 @@ LFL = -L$(thrift_home)/lib/cpp/.libs -lthrift
CCFL = -Wall -O3 -g -I./gen-cpp $(include_flags)
CFL = $(CCFL) $(LFL)
-all: server
+all: server client
stubs: ThreadsTest.thrift
$(THRIFT) -cpp -py ThreadsTest.thrift
@@ -42,5 +42,8 @@ stubs: ThreadsTest.thrift
server: stubs
g++ -o ThreadsServer $(CFL) ThreadsServer.cpp ./gen-cpp/ThreadsTest.cpp ./gen-cpp/ThreadsTest_types.cpp
+client: stubs
+ g++ -o ThreadsClient $(CFL) ThreadsClient.cpp ./gen-cpp/ThreadsTest.cpp ./gen-cpp/ThreadsTest_types.cpp
+
clean:
rm -fr *.o ThreadsServer gen-cpp
diff --git a/test/threads/ThreadsClient.cpp b/test/threads/ThreadsClient.cpp
new file mode 100644
index 000000000..d8f67669c
--- /dev/null
+++ b/test/threads/ThreadsClient.cpp
@@ -0,0 +1,43 @@
+// This autogenerated skeleton file illustrates how to build a server.
+// You should copy it to another filename to avoid overwriting it.
+
+#include "ThreadsTest.h"
+#include <protocol/TBinaryProtocol.h>
+#include <server/TThreadPoolServer.h>
+#include <transport/TSocket.h>
+#include <transport/TTransportUtils.h>
+#include <thrift/concurrency/Monitor.h>
+#include <thrift/concurrency/ThreadManager.h>
+#include <thrift/concurrency/PosixThreadFactory.h>
+
+using namespace facebook::thrift;
+using namespace facebook::thrift::protocol;
+using namespace facebook::thrift::transport;
+using namespace facebook::thrift::server;
+using namespace facebook::thrift::concurrency;
+
+int main(int argc, char **argv) {
+ int port = 9090;
+ std::string host = "localhost";
+
+ shared_ptr<TTransport> transport(new TSocket(host, port));
+ shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));
+
+ transport->open();
+
+ ThreadsTestClient client(protocol);
+ int val;
+ val = client.threadOne(5);
+ fprintf(stderr, "%d\n", val);
+ val = client.stop();
+ fprintf(stderr, "%d\n", val);
+ val = client.threadTwo(5);
+ fprintf(stderr, "%d\n", val);
+
+ transport->close();
+
+ fprintf(stderr, "done.\n");
+
+ return 0;
+}
+
diff --git a/test/threads/ThreadsServer.cpp b/test/threads/ThreadsServer.cpp
index 1e3494cc3..f5bd665c6 100644
--- a/test/threads/ThreadsServer.cpp
+++ b/test/threads/ThreadsServer.cpp
@@ -23,33 +23,38 @@ class ThreadsTestHandler : virtual public ThreadsTestIf {
// Your initialization goes here
}
- void threadOne(const int32_t sleep) {
+ int32_t threadOne(const int32_t sleep) {
// Your implementation goes here
printf("threadOne\n");
go2sleep(1, sleep);
+ return 1;
}
- void threadTwo(const int32_t sleep) {
+ int32_t threadTwo(const int32_t sleep) {
// Your implementation goes here
printf("threadTwo\n");
go2sleep(2, sleep);
+ return 1;
}
- void threadThree(const int32_t sleep) {
+ int32_t threadThree(const int32_t sleep) {
// Your implementation goes here
printf("threadThree\n");
go2sleep(3, sleep);
+ return 1;
}
- void threadFour(const int32_t sleep) {
+ int32_t threadFour(const int32_t sleep) {
// Your implementation goes here
printf("threadFour\n");
go2sleep(4, sleep);
+ return 1;
}
- void stop() {
+ int32_t stop() {
printf("stop\n");
server_->stop();
+ return 1;
}
void setServer(boost::shared_ptr<TServer> server) {
diff --git a/test/threads/ThreadsTest.thrift b/test/threads/ThreadsTest.thrift
index ebf2513e8..ed071e5d7 100755
--- a/test/threads/ThreadsTest.thrift
+++ b/test/threads/ThreadsTest.thrift
@@ -1,11 +1,11 @@
#!/usr/local/bin/thrift -cpp -py
service ThreadsTest {
- void threadOne(1: i32 sleep=15),
- void threadTwo(2: i32 sleep=15),
- void threadThree(3: i32 sleep=15),
- void threadFour(4: i32 sleep=15)
+ i32 threadOne(1: i32 sleep=15),
+ i32 threadTwo(2: i32 sleep=15),
+ i32 threadThree(3: i32 sleep=15),
+ i32 threadFour(4: i32 sleep=15)
- void stop();
+ i32 stop();
}