David Reiss | ea2cba8 | 2009-03-30 21:35:00 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | |
Mark Slee | c416a27 | 2007-03-05 05:40:37 +0000 | [diff] [blame] | 20 | // This autogenerated skeleton file illustrates how to build a server. |
| 21 | // You should copy it to another filename to avoid overwriting it. |
| 22 | |
| 23 | #include "ThreadsTest.h" |
Roger Meier | 49ff8b1 | 2012-04-13 09:12:31 +0000 | [diff] [blame] | 24 | #include <thrift/protocol/TBinaryProtocol.h> |
| 25 | #include <thrift/server/TThreadPoolServer.h> |
| 26 | #include <thrift/transport/TSocket.h> |
| 27 | #include <thrift/transport/TTransportUtils.h> |
| 28 | #include <thrift/concurrency/Monitor.h> |
| 29 | #include <thrift/concurrency/ThreadManager.h> |
cyy | ca8af9b | 2019-01-11 22:13:12 +0800 | [diff] [blame] | 30 | #include <thrift/concurrency/ThreadFactory.h> |
Jake Farrell | 5d02b80 | 2014-01-07 21:42:01 -0500 | [diff] [blame] | 31 | #if _WIN32 |
| 32 | #include <thrift/windows/TWinsockSingleton.h> |
| 33 | #endif |
Mark Slee | c416a27 | 2007-03-05 05:40:37 +0000 | [diff] [blame] | 34 | |
Mark Slee | 02d1edc | 2007-03-07 05:17:25 +0000 | [diff] [blame] | 35 | using boost::shared_ptr; |
T Jake Luciani | b5e6221 | 2009-01-31 22:36:20 +0000 | [diff] [blame] | 36 | using namespace apache::thrift; |
| 37 | using namespace apache::thrift::protocol; |
| 38 | using namespace apache::thrift::transport; |
| 39 | using namespace apache::thrift::server; |
| 40 | using namespace apache::thrift::concurrency; |
Mark Slee | c416a27 | 2007-03-05 05:40:37 +0000 | [diff] [blame] | 41 | |
| 42 | int main(int argc, char **argv) { |
Jake Farrell | 5d02b80 | 2014-01-07 21:42:01 -0500 | [diff] [blame] | 43 | #if _WIN32 |
| 44 | transport::TWinsockSingleton::create(); |
| 45 | #endif |
Mark Slee | c416a27 | 2007-03-05 05:40:37 +0000 | [diff] [blame] | 46 | int port = 9090; |
| 47 | std::string host = "localhost"; |
| 48 | |
| 49 | shared_ptr<TTransport> transport(new TSocket(host, port)); |
| 50 | shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport)); |
| 51 | |
| 52 | transport->open(); |
| 53 | |
| 54 | ThreadsTestClient client(protocol); |
| 55 | int val; |
| 56 | val = client.threadOne(5); |
| 57 | fprintf(stderr, "%d\n", val); |
| 58 | val = client.stop(); |
| 59 | fprintf(stderr, "%d\n", val); |
| 60 | val = client.threadTwo(5); |
| 61 | fprintf(stderr, "%d\n", val); |
| 62 | |
| 63 | transport->close(); |
| 64 | |
| 65 | fprintf(stderr, "done.\n"); |
| 66 | |
| 67 | return 0; |
| 68 | } |
| 69 | |