`make style` applied
Project: http://git-wip-us.apache.org/repos/asf/thrift/repo Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/1f6e380c Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/1f6e380c Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/1f6e380c Branch: refs/heads/master Commit: 1f6e380c5d07686e4cd8c2b172300a1ba7fbd8b9 Parents: 3b115df Author: Konrad Grochowski <[email protected]> Authored: Mon May 18 18:10:06 2015 +0200 Committer: Konrad Grochowski <[email protected]> Committed: Mon May 18 19:47:28 2015 +0200 ---------------------------------------------------------------------- build/cmake/DefineCMakeDefaults.cmake | 2 +- build/cmake/config.h.in | 2 +- compiler/cpp/src/generate/t_c_glib_generator.cc | 6 +- compiler/cpp/src/generate/t_cocoa_generator.cc | 62 ++-- compiler/cpp/src/generate/t_csharp_generator.cc | 9 +- compiler/cpp/src/generate/t_go_generator.cc | 84 ++--- compiler/cpp/src/generate/t_gv_generator.cc | 7 +- compiler/cpp/src/generate/t_haxe_generator.cc | 3 +- compiler/cpp/src/generate/t_java_generator.cc | 63 ++-- compiler/cpp/src/generate/t_lua_generator.cc | 34 +- compiler/cpp/src/generate/t_rb_generator.cc | 9 +- compiler/cpp/src/parse/t_enum.h | 2 +- lib/cpp/src/thrift/TOutput.h | 1 - lib/cpp/src/thrift/protocol/TJSONProtocol.cpp | 12 +- lib/cpp/src/thrift/server/TConnectedClient.cpp | 54 ++- lib/cpp/src/thrift/server/TConnectedClient.h | 122 +++---- .../src/thrift/server/TNonblockingServer.cpp | 4 +- lib/cpp/src/thrift/server/TNonblockingServer.h | 6 +- lib/cpp/src/thrift/server/TServerFramework.cpp | 111 +++--- lib/cpp/src/thrift/server/TServerFramework.h | 45 ++- lib/cpp/src/thrift/server/TSimpleServer.cpp | 79 ++-- lib/cpp/src/thrift/server/TSimpleServer.h | 49 +-- lib/cpp/src/thrift/server/TThreadPoolServer.cpp | 104 +++--- lib/cpp/src/thrift/server/TThreadPoolServer.h | 59 ++- lib/cpp/src/thrift/server/TThreadedServer.cpp | 89 ++--- lib/cpp/src/thrift/server/TThreadedServer.h | 71 ++-- .../src/thrift/transport/TBufferTransports.cpp | 11 +- lib/cpp/src/thrift/transport/TFileTransport.cpp | 2 +- .../src/thrift/transport/TSSLServerSocket.cpp | 3 +- lib/cpp/src/thrift/transport/TSSLServerSocket.h | 3 +- lib/cpp/src/thrift/transport/TServerSocket.cpp | 43 ++- lib/cpp/src/thrift/transport/TSocket.cpp | 50 ++- lib/cpp/src/thrift/transport/TSocket.h | 3 +- lib/cpp/test/TFDTransportTest.cpp | 4 +- lib/cpp/test/TMemoryBufferTest.cpp | 21 +- lib/cpp/test/TServerIntegrationTest.cpp | 361 +++++++++---------- lib/cpp/test/TServerSocketTest.cpp | 53 ++- lib/cpp/test/TServerTransportTest.cpp | 41 +-- lib/cpp/test/TSocketInterruptTest.cpp | 190 +++++----- lib/cpp/test/TTransportCheckThrow.h | 33 +- lib/cpp/test/TestPortFixture.h | 19 +- lib/cpp/test/TypedefTest.cpp | 3 +- test/cpp/src/TestClient.cpp | 1 - test/cpp/src/TestServer.cpp | 3 +- test/crossrunner/collect.py | 2 +- 45 files changed, 962 insertions(+), 973 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/thrift/blob/1f6e380c/build/cmake/DefineCMakeDefaults.cmake ---------------------------------------------------------------------- diff --git a/build/cmake/DefineCMakeDefaults.cmake b/build/cmake/DefineCMakeDefaults.cmake index f41673e..7073e8e 100644 --- a/build/cmake/DefineCMakeDefaults.cmake +++ b/build/cmake/DefineCMakeDefaults.cmake @@ -26,7 +26,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) # Put the include dirs which are in the source or build tree # before all other include dirs, so the headers in the sources -# are prefered over the already installed ones +# are preferred over the already installed ones # since cmake 2.4.1 set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON) http://git-wip-us.apache.org/repos/asf/thrift/blob/1f6e380c/build/cmake/config.h.in ---------------------------------------------------------------------- diff --git a/build/cmake/config.h.in b/build/cmake/config.h.in index 8b75e8c..181ea18 100644 --- a/build/cmake/config.h.in +++ b/build/cmake/config.h.in @@ -63,7 +63,7 @@ #define SIGNED_RIGHT_SHIFT_IS 1 /* Use *.h extension for parser header file */ -/* TODO: This might now be necessary anymore as it is set onyl for automake < 1.11 +/* TODO: This might now be necessary anymore as it is set only for automake < 1.11 see: aclocal/ac_prog_bison.m4 */ #cmakedefine BISON_USE_PARSER_H_EXTENSION 1 http://git-wip-us.apache.org/repos/asf/thrift/blob/1f6e380c/compiler/cpp/src/generate/t_c_glib_generator.cc ---------------------------------------------------------------------- diff --git a/compiler/cpp/src/generate/t_c_glib_generator.cc b/compiler/cpp/src/generate/t_c_glib_generator.cc index 098f63b..dfdd4ef 100644 --- a/compiler/cpp/src/generate/t_c_glib_generator.cc +++ b/compiler/cpp/src/generate/t_c_glib_generator.cc @@ -1804,9 +1804,9 @@ void t_c_glib_generator::generate_service_handler(t_service* tservice) { indent(f_service_) << function_signature(&implementing_function) << endl; scope_up(f_service_); - f_service_ << indent() << "g_return_val_if_fail (" << this->nspace_uc << "IS_" << service_name_uc - << "_HANDLER (iface), FALSE);" << endl << endl << indent() << "return " << class_name_uc - << "_GET_CLASS (iface)" + f_service_ << indent() << "g_return_val_if_fail (" << this->nspace_uc << "IS_" + << service_name_uc << "_HANDLER (iface), FALSE);" << endl << endl << indent() + << "return " << class_name_uc << "_GET_CLASS (iface)" << "->" << method_name << " (iface, "; if (!return_type->is_void()) { http://git-wip-us.apache.org/repos/asf/thrift/blob/1f6e380c/compiler/cpp/src/generate/t_cocoa_generator.cc ---------------------------------------------------------------------- diff --git a/compiler/cpp/src/generate/t_cocoa_generator.cc b/compiler/cpp/src/generate/t_cocoa_generator.cc index e3e1842..a90c937 100644 --- a/compiler/cpp/src/generate/t_cocoa_generator.cc +++ b/compiler/cpp/src/generate/t_cocoa_generator.cc @@ -136,9 +136,11 @@ public: void generate_cocoa_service_client_interface(std::ofstream& out, t_service* tservice); void generate_cocoa_service_client_async_interface(std::ofstream& out, t_service* tservice); - void generate_cocoa_service_client_send_function_implementation(ofstream& out, t_function* tfunction); + void generate_cocoa_service_client_send_function_implementation(ofstream& out, + t_function* tfunction); void generate_cocoa_service_client_send_function_invocation(ofstream& out, t_function* tfunction); - void generate_cocoa_service_client_recv_function_implementation(ofstream& out, t_function* tfunction); + void generate_cocoa_service_client_recv_function_implementation(ofstream& out, + t_function* tfunction); void generate_cocoa_service_client_implementation(std::ofstream& out, t_service* tservice); void generate_cocoa_service_client_async_implementation(std::ofstream& out, t_service* tservice); @@ -1229,7 +1231,7 @@ void t_cocoa_generator::generate_service(t_service* tservice) { generate_cocoa_service_helpers(tservice); generate_cocoa_service_client_implementation(f_impl_, tservice); generate_cocoa_service_server_implementation(f_impl_, tservice); - if(async_clients_) { + if (async_clients_) { generate_cocoa_service_async_protocol(f_header_, tservice); generate_cocoa_service_client_async_interface(f_header_, tservice); generate_cocoa_service_client_async_implementation(f_impl_, tservice); @@ -1324,7 +1326,8 @@ void t_cocoa_generator::generate_cocoa_service_protocol(ofstream& out, t_service * @param tservice The service to generate a protocol definition for */ void t_cocoa_generator::generate_cocoa_service_async_protocol(ofstream& out, t_service* tservice) { - out << "@protocol " << cocoa_prefix_ << tservice->get_name() << "Async" << " <NSObject>" << endl; + out << "@protocol " << cocoa_prefix_ << tservice->get_name() << "Async" + << " <NSObject>" << endl; vector<t_function*> functions = tservice->get_functions(); vector<t_function*>::iterator f_iter; @@ -1393,8 +1396,9 @@ void t_cocoa_generator::generate_cocoa_service_server_interface(ofstream& out, out << "@end" << endl << endl; } -void t_cocoa_generator::generate_cocoa_service_client_send_function_implementation(ofstream& out, - t_function* tfunction) { +void t_cocoa_generator::generate_cocoa_service_client_send_function_implementation( + ofstream& out, + t_function* tfunction) { string funname = tfunction->get_name(); t_function send_function(g_type_void, @@ -1446,8 +1450,9 @@ void t_cocoa_generator::generate_cocoa_service_client_send_function_implementati out << endl; } -void t_cocoa_generator::generate_cocoa_service_client_recv_function_implementation(ofstream& out, - t_function* tfunction) { +void t_cocoa_generator::generate_cocoa_service_client_recv_function_implementation( + ofstream& out, + t_function* tfunction) { t_struct noargs(program_); t_function recv_function(tfunction->get_returntype(), string("recv_") + tfunction->get_name(), @@ -1468,8 +1473,8 @@ void t_cocoa_generator::generate_cocoa_service_client_recv_function_implementati // FIXME - could optimize here to reduce creation of temporary objects. string resultname = function_result_helper_struct_type(tfunction); - out << indent() << cocoa_prefix_ << resultname << " * result = [[[" << cocoa_prefix_ - << resultname << " alloc] init] autorelease_stub];" << endl; + out << indent() << cocoa_prefix_ << resultname << " * result = [[[" << cocoa_prefix_ << resultname + << " alloc] init] autorelease_stub];" << endl; indent(out) << "[result read: inProtocol];" << endl; indent(out) << "[inProtocol readMessageEnd];" << endl; @@ -1483,9 +1488,8 @@ void t_cocoa_generator::generate_cocoa_service_client_recv_function_implementati const std::vector<t_field*>& xceptions = xs->get_members(); vector<t_field*>::const_iterator x_iter; for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) { - out << indent() << "if ([result " << (*x_iter)->get_name() << "IsSet]) {" << endl - << indent() << " @throw [result " << (*x_iter)->get_name() << "];" << endl << indent() - << "}" << endl; + out << indent() << "if ([result " << (*x_iter)->get_name() << "IsSet]) {" << endl << indent() + << " @throw [result " << (*x_iter)->get_name() << "];" << endl << indent() << "}" << endl; } // If you get here it's an exception, unless a void function @@ -1508,8 +1512,9 @@ void t_cocoa_generator::generate_cocoa_service_client_recv_function_implementati * * @param tfunction The service to generate an implementation for */ -void t_cocoa_generator::generate_cocoa_service_client_send_function_invocation(ofstream& out, - t_function* tfunction) { +void t_cocoa_generator::generate_cocoa_service_client_send_function_invocation( + ofstream& out, + t_function* tfunction) { t_struct* arg_struct = tfunction->get_arglist(); const vector<t_field*>& fields = arg_struct->get_members(); vector<t_field*>::const_iterator fld_iter; @@ -1558,7 +1563,7 @@ void t_cocoa_generator::generate_cocoa_service_client_implementation(ofstream& o vector<t_function*> functions = tservice->get_functions(); vector<t_function*>::const_iterator f_iter; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { - + generate_cocoa_service_client_send_function_implementation(out, *f_iter); if (!(*f_iter)->is_oneway()) { @@ -1569,7 +1574,7 @@ void t_cocoa_generator::generate_cocoa_service_client_implementation(ofstream& o indent(out) << "- " << function_signature(*f_iter) << endl; scope_up(out); generate_cocoa_service_client_send_function_invocation(out, *f_iter); - + out << indent() << "[[outProtocol transport] flush];" << endl; if (!(*f_iter)->is_oneway()) { out << indent(); @@ -1592,13 +1597,14 @@ void t_cocoa_generator::generate_cocoa_service_client_implementation(ofstream& o */ void t_cocoa_generator::generate_cocoa_service_client_async_implementation(ofstream& out, t_service* tservice) { - out << "@implementation " << cocoa_prefix_ << tservice->get_name() << "ClientAsync" << endl << endl - << "- (id) initWithProtocolFactory: (id <TProtocolFactory>) factory " - "transport: (id <TAsyncTransport>) transport;" << endl; + out << "@implementation " << cocoa_prefix_ << tservice->get_name() << "ClientAsync" << endl + << endl << "- (id) initWithProtocolFactory: (id <TProtocolFactory>) factory " + "transport: (id <TAsyncTransport>) transport;" << endl; scope_up(out); out << indent() << "self = [super init];" << endl; - out << indent() << "inProtocol = [[factory newProtocolOnTransport:transport] retain_stub];" << endl; + out << indent() << "inProtocol = [[factory newProtocolOnTransport:transport] retain_stub];" + << endl; out << indent() << "outProtocol = inProtocol;" << endl; out << indent() << "asyncTransport = transport;" << endl; out << indent() << "return self;" << endl; @@ -1609,7 +1615,7 @@ void t_cocoa_generator::generate_cocoa_service_client_async_implementation(ofstr vector<t_function*> functions = tservice->get_functions(); vector<t_function*>::const_iterator f_iter; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { - + generate_cocoa_service_client_send_function_implementation(out, *f_iter); if (!(*f_iter)->is_oneway()) { @@ -1625,11 +1631,10 @@ void t_cocoa_generator::generate_cocoa_service_client_async_implementation(ofstr indent_down(); out << indent() << "} @catch(TException * texception) {" << endl; indent_up(); - out << indent() << "failureBlock(texception);" << endl - << indent() << "return;" << endl; + out << indent() << "failureBlock(texception);" << endl << indent() << "return;" << endl; indent_down(); indent(out) << "}" << endl; - + out << indent() << "[asyncTransport flush:^{" << endl; indent_up(); @@ -2719,10 +2724,9 @@ string t_cocoa_generator::async_function_signature(t_function* tfunction) { if (!ttype->is_void()) { response_param = "void (^)(" + type_name(ttype) + ")"; } - std::string result = "(void) " + tfunction->get_name() - + argument_list(tfunction->get_arglist()) - + (targlist->get_members().size() ? " response" : "") - + ": (" + response_param + ") responseBlock " + std::string result = "(void) " + tfunction->get_name() + argument_list(tfunction->get_arglist()) + + (targlist->get_members().size() ? " response" : "") + ": (" + + response_param + ") responseBlock " + "failure : (TAsyncFailureBlock) failureBlock"; return result; } http://git-wip-us.apache.org/repos/asf/thrift/blob/1f6e380c/compiler/cpp/src/generate/t_csharp_generator.cc ---------------------------------------------------------------------- diff --git a/compiler/cpp/src/generate/t_csharp_generator.cc b/compiler/cpp/src/generate/t_csharp_generator.cc index 586ab75..d6aad75 100644 --- a/compiler/cpp/src/generate/t_csharp_generator.cc +++ b/compiler/cpp/src/generate/t_csharp_generator.cc @@ -1719,7 +1719,7 @@ void t_csharp_generator::generate_service_client(t_service* tservice) { scope_up(f_service_); t_struct* xs = (*f_iter)->get_xceptions(); - prepare_member_name_mapping(xs,xs->get_members(),resultname); + prepare_member_name_mapping(xs, xs->get_members(), resultname); f_service_ << indent() << "TMessage msg = iprot_.ReadMessageBegin();" << endl << indent() << "if (msg.Type == TMessageType.Exception) {" << endl; @@ -1945,7 +1945,7 @@ void t_csharp_generator::generate_process_function(t_service* tservice, t_functi if (!tfunction->is_oneway() && xceptions.size() > 0) { indent_down(); f_service_ << indent() << "}"; - prepare_member_name_mapping(xs,xs->get_members(),resultname); + prepare_member_name_mapping(xs, xs->get_members(), resultname); for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) { f_service_ << " catch (" << type_name((*x_iter)->get_type(), false, false) << " " << (*x_iter)->get_name() << ") {" << endl; @@ -2512,11 +2512,10 @@ void t_csharp_generator::prepare_member_name_mapping(void* scope, // current C# generator policy: // - prop names are always rendered with an Uppercase first letter // - struct names are used as given - - + // prevent name conflicts with struct (CS0542 error) used_member_names.insert(structname); - + // prevent name conflicts with known methods (THRIFT-2942) used_member_names.insert("Read"); used_member_names.insert("Write"); http://git-wip-us.apache.org/repos/asf/thrift/blob/1f6e380c/compiler/cpp/src/generate/t_go_generator.cc ---------------------------------------------------------------------- diff --git a/compiler/cpp/src/generate/t_go_generator.cc b/compiler/cpp/src/generate/t_go_generator.cc index 82340fd..0030d24 100644 --- a/compiler/cpp/src/generate/t_go_generator.cc +++ b/compiler/cpp/src/generate/t_go_generator.cc @@ -134,9 +134,9 @@ public: const string& tstruct_name, bool is_result = false); void generate_countsetfields_helper(std::ofstream& out, - t_struct* tstruct, - const string& tstruct_name, - bool is_result = false); + t_struct* tstruct, + const string& tstruct_name, + bool is_result = false); void generate_go_struct_reader(std::ofstream& out, t_struct* tstruct, const string& tstruct_name, @@ -413,21 +413,22 @@ bool t_go_generator::is_pointer_field(t_field* tfield, bool in_container_value) std::string t_go_generator::camelcase(const std::string& value) const { std::string value2(value); std::setlocale(LC_ALL, "C"); // set locale to classic - - // as long as we are changing things, let's change _ followed by lowercase to capital and fix common initialisms + + // as long as we are changing things, let's change _ followed by lowercase to capital and fix + // common initialisms for (std::string::size_type i = 1; i < value2.size() - 1; ++i) { - if (value2[i] == '_'){ + if (value2[i] == '_') { if (islower(value2[i + 1])) { value2.replace(i, 2, 1, toupper(value2[i + 1])); } - std::string word = value2.substr(i,value2.find('_', i)); + std::string word = value2.substr(i, value2.find('_', i)); std::transform(word.begin(), word.end(), word.begin(), ::toupper); if (commonInitialisms.find(word) != commonInitialisms.end()) { - value2.replace(i, word.length(), word); + value2.replace(i, word.length(), word); } } } - + return value2; } @@ -878,16 +879,16 @@ void t_go_generator::generate_enum(t_enum* tenum) { f_types_ << indent() << " " << tenum_name << "_" << iter_name << ' ' << tenum_name << " = " << value << endl; // Dictionaries to/from string names of enums - to_string_mapping << indent() << " case " << tenum_name << "_" << iter_name - << ": return \"" << iter_std_name << "\"" << endl; + to_string_mapping << indent() << " case " << tenum_name << "_" << iter_name << ": return \"" + << iter_std_name << "\"" << endl; if (iter_std_name != escape_string(iter_name)) { from_string_mapping << indent() << " case \"" << iter_std_name << "\", \"" - << escape_string(iter_name) << "\": return " << tenum_name - << "_" << iter_name << ", nil " << endl; + << escape_string(iter_name) << "\": return " << tenum_name << "_" + << iter_name << ", nil " << endl; } else { - from_string_mapping << indent() << " case \"" << iter_std_name << "\": return " - << tenum_name << "_" << iter_name << ", nil " << endl; + from_string_mapping << indent() << " case \"" << iter_std_name << "\": return " << tenum_name + << "_" << iter_name << ", nil " << endl; } } @@ -1188,9 +1189,8 @@ void t_go_generator::generate_go_struct_definition(ofstream& out, if (it != (*m_iter)->annotations_.end()) { gotag = it->second; } - indent(out) << publicize((*m_iter)->get_name()) << " " << goType - << " `thrift:\"" << escape_string((*m_iter)->get_name()) << "," - << sorted_keys_pos; + indent(out) << publicize((*m_iter)->get_name()) << " " << goType << " `thrift:\"" + << escape_string((*m_iter)->get_name()) << "," << sorted_keys_pos; if ((*m_iter)->get_req() == t_field::T_REQUIRED) { out << ",required"; @@ -1248,7 +1248,6 @@ void t_go_generator::generate_go_struct_definition(ofstream& out, } } - if (tstruct->is_union() && num_setable > 0) { generate_countsetfields_helper(out, tstruct, tstruct_name, is_result); } @@ -1285,8 +1284,7 @@ void t_go_generator::generate_isset_helpers(ofstream& out, const string escaped_tstruct_name(escape_string(tstruct->get_name())); for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { - const string field_name( - publicize(escape_string((*f_iter)->get_name()))); + const string field_name(publicize(escape_string((*f_iter)->get_name()))); if ((*f_iter)->get_req() == t_field::T_OPTIONAL || is_pointer_field(*f_iter)) { out << indent() << "func (p *" << tstruct_name << ") IsSet" << field_name << "() bool {" << endl; @@ -1316,16 +1314,15 @@ void t_go_generator::generate_isset_helpers(ofstream& out, * Generates the CountSetFields helper method for a struct */ void t_go_generator::generate_countsetfields_helper(ofstream& out, - t_struct* tstruct, - const string& tstruct_name, - bool is_result) { + t_struct* tstruct, + const string& tstruct_name, + bool is_result) { (void)is_result; const vector<t_field*>& fields = tstruct->get_members(); vector<t_field*>::const_iterator f_iter; const string escaped_tstruct_name(escape_string(tstruct->get_name())); - out << indent() << "func (p *" << tstruct_name << ") CountSetFields" << tstruct_name - << "() int {" + out << indent() << "func (p *" << tstruct_name << ") CountSetFields" << tstruct_name << "() int {" << endl; indent_up(); out << indent() << "count := 0" << endl; @@ -1336,8 +1333,7 @@ void t_go_generator::generate_countsetfields_helper(ofstream& out, if (!is_pointer_field(*f_iter)) continue; - const string field_name( - publicize(escape_string((*f_iter)->get_name()))); + const string field_name(publicize(escape_string((*f_iter)->get_name()))); out << indent() << "if (p.IsSet" << field_name << "()) {" << endl; indent_up(); @@ -1351,7 +1347,6 @@ void t_go_generator::generate_countsetfields_helper(ofstream& out, out << indent() << "}" << endl << endl; } - /** * Generates the read method for a struct */ @@ -1374,8 +1369,7 @@ void t_go_generator::generate_go_struct_reader(ofstream& out, // Required variables does not have IsSet functions, so we need tmp vars to check them. for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { if ((*f_iter)->get_req() == t_field::T_REQUIRED) { - const string field_name( - publicize(escape_string((*f_iter)->get_name()))); + const string field_name(publicize(escape_string((*f_iter)->get_name()))); indent(out) << "var isset" << field_name << " bool = false;" << endl; } } @@ -1430,8 +1424,7 @@ void t_go_generator::generate_go_struct_reader(ofstream& out, // Mark required field as read if ((*f_iter)->get_req() == t_field::T_REQUIRED) { - const string field_name( - publicize(escape_string((*f_iter)->get_name()))); + const string field_name(publicize(escape_string((*f_iter)->get_name()))); out << indent() << "isset" << field_name << " = true" << endl; } @@ -1469,8 +1462,7 @@ void t_go_generator::generate_go_struct_reader(ofstream& out, // Return error if any required fields are missing. for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { if ((*f_iter)->get_req() == t_field::T_REQUIRED) { - const string field_name( - publicize(escape_string((*f_iter)->get_name()))); + const string field_name(publicize(escape_string((*f_iter)->get_name()))); out << indent() << "if !isset" << field_name << "{" << endl; out << indent() << " return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, " "fmt.Errorf(\"Required field " << field_name << " is not set\"));" << endl; @@ -1517,8 +1509,9 @@ void t_go_generator::generate_go_struct_writer(ofstream& out, if (tstruct->is_union() && uses_countsetfields) { std::string tstruct_name(publicize(tstruct->get_name())); out << indent() << "if c := p.CountSetFields" << tstruct_name << "(); c != 1 {" << endl - << indent() << " return fmt.Errorf(\"%T write union: exactly one field must be set (%d set).\", p, c)" << endl - << indent() << "}" << endl; + << indent() + << " return fmt.Errorf(\"%T write union: exactly one field must be set (%d set).\", p, c)" + << endl << indent() << "}" << endl; } out << indent() << "if err := oprot.WriteStructBegin(\"" << name << "\"); err != nil {" << endl; out << indent() << " return thrift.PrependError(fmt.Sprintf(" @@ -1572,8 +1565,7 @@ void t_go_generator::generate_go_struct_writer(ofstream& out, indent_up(); if (field_required == t_field::T_OPTIONAL) { - out << indent() << "if p.IsSet" << publicize(field_name) << "() {" - << endl; + out << indent() << "if p.IsSet" << publicize(field_name) << "() {" << endl; indent_up(); } @@ -1883,8 +1875,8 @@ void t_go_generator::generate_service_client(t_service* tservice) { f_service_ << indent() << "args := " << argsname << "{" << endl; for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) { - f_service_ << indent() << publicize((*fld_iter)->get_name()) - << " : " << variable_name_to_go_name((*fld_iter)->get_name()) << "," << endl; + f_service_ << indent() << publicize((*fld_iter)->get_name()) << " : " + << variable_name_to_go_name((*fld_iter)->get_name()) << "," << endl; } f_service_ << indent() << "}" << endl; @@ -2030,7 +2022,7 @@ void t_go_generator::generate_service_remote(t_service* tservice) { while ((loc = service_module.find(".")) != string::npos) { service_module.replace(loc, 1, 1, '/'); } - if(!gen_package_prefix_.empty()) { + if (!gen_package_prefix_.empty()) { service_module = gen_package_prefix_ + service_module; } @@ -2631,8 +2623,7 @@ void t_go_generator::generate_process_function(t_service* tservice, t_function* for (xf_iter = x_fields.begin(); xf_iter != x_fields.end(); ++xf_iter) { f_service_ << indent() << " case " << type_to_go_type(((*xf_iter)->get_type())) << ":" << endl; - f_service_ << indent() << "result." - << publicize((*xf_iter)->get_name()) << " = v" << endl; + f_service_ << indent() << "result." << publicize((*xf_iter)->get_name()) << " = v" << endl; } f_service_ << indent() << " default:" << endl; @@ -2731,11 +2722,10 @@ void t_go_generator::generate_deserialize_field(ofstream& out, } else if (type->is_base_type() || type->is_enum()) { if (declare) { - t_type* actual_type = use_true_type ? tfield->get_type()->get_true_type() + t_type* actual_type = use_true_type ? tfield->get_type()->get_true_type() : tfield->get_type(); - string type_name = inkey ? type_to_go_key_type(actual_type) - : type_to_go_type(actual_type); + string type_name = inkey ? type_to_go_key_type(actual_type) : type_to_go_type(actual_type); out << "var " << tfield->get_name() << " " << type_name << endl; } http://git-wip-us.apache.org/repos/asf/thrift/blob/1f6e380c/compiler/cpp/src/generate/t_gv_generator.cc ---------------------------------------------------------------------- diff --git a/compiler/cpp/src/generate/t_gv_generator.cc b/compiler/cpp/src/generate/t_gv_generator.cc index 59e06a0..b70f2ca 100644 --- a/compiler/cpp/src/generate/t_gv_generator.cc +++ b/compiler/cpp/src/generate/t_gv_generator.cc @@ -301,8 +301,7 @@ void t_gv_generator::generate_service(t_service* tservice) { f_out_ << "function_" << service_name << fn_name; f_out_ << "[label=\"<return_type>function " << escape_string(fn_name); f_out_ << " :: "; - print_type((*fn_iter)->get_returntype(), - "function_" + service_name + fn_name + ":return_type"); + print_type((*fn_iter)->get_returntype(), "function_" + service_name + fn_name + ":return_type"); vector<t_field*> args = (*fn_iter)->get_arglist()->get_members(); vector<t_field*>::iterator arg_iter = args.begin(); @@ -314,8 +313,8 @@ void t_gv_generator::generate_service(t_service* tservice) { print_const_value((*arg_iter)->get_type(), (*arg_iter)->get_value()); } f_out_ << " :: "; - print_type((*arg_iter)->get_type(), "function_" + service_name + fn_name - + ":param_" + (*arg_iter)->get_name()); + print_type((*arg_iter)->get_type(), + "function_" + service_name + fn_name + ":param_" + (*arg_iter)->get_name()); } // end of node f_out_ << "\"];" << endl; http://git-wip-us.apache.org/repos/asf/thrift/blob/1f6e380c/compiler/cpp/src/generate/t_haxe_generator.cc ---------------------------------------------------------------------- diff --git a/compiler/cpp/src/generate/t_haxe_generator.cc b/compiler/cpp/src/generate/t_haxe_generator.cc index 3c4dadf..a0e2f28 100644 --- a/compiler/cpp/src/generate/t_haxe_generator.cc +++ b/compiler/cpp/src/generate/t_haxe_generator.cc @@ -200,7 +200,8 @@ public: t_base_type::t_base tbase = ((t_base_type*)ttype)->get_base(); switch (tbase) { case t_base_type::TYPE_STRING: - //case t_base_type::TYPE_I64: - Int64 is not really nullable, even though it behaved that way before Haxe 3.2.0 + // case t_base_type::TYPE_I64: - Int64 is not really nullable, even though it behaved that + // way before Haxe 3.2.0 return true; default: return false; http://git-wip-us.apache.org/repos/asf/thrift/blob/1f6e380c/compiler/cpp/src/generate/t_java_generator.cc ---------------------------------------------------------------------- diff --git a/compiler/cpp/src/generate/t_java_generator.cc b/compiler/cpp/src/generate/t_java_generator.cc index c45c798..8c05d4a 100644 --- a/compiler/cpp/src/generate/t_java_generator.cc +++ b/compiler/cpp/src/generate/t_java_generator.cc @@ -398,8 +398,7 @@ string t_java_generator::java_type_imports() { } if (use_option_type_) { - option = string() + - "import org.apache.thrift.Option;\n"; + option = string() + "import org.apache.thrift.Option;\n"; } return string() + hash_builder + "import org.apache.thrift.scheme.IScheme;\n" @@ -702,7 +701,7 @@ string t_java_generator::render_const_value(ofstream& out, t_type* type, t_const } else if (type->is_enum()) { std::string namespace_prefix = type->get_program()->get_namespace("java"); if (namespace_prefix.length() > 0) { - namespace_prefix += "."; + namespace_prefix += "."; } render << namespace_prefix << value->get_identifier_with_parent(); } else { @@ -2164,8 +2163,8 @@ void t_java_generator::generate_java_bean_boilerplate(ofstream& out, t_struct* t out << get_cap_name("size() {") << endl; indent_up(); - indent(out) << "return (this." << field_name << " == null) ? 0 : " << - "this." << field_name << ".size();" << endl; + indent(out) << "return (this." << field_name << " == null) ? 0 : " + << "this." << field_name << ".size();" << endl; indent_down(); indent(out) << "}" << endl << endl; } @@ -2181,8 +2180,8 @@ void t_java_generator::generate_java_bean_boilerplate(ofstream& out, t_struct* t // Iterator getter for sets and lists if (optional) { - indent(out) << "public Option<java.util.Iterator<" << - type_name(element_type, true, false) << ">> get" << cap_name; + indent(out) << "public Option<java.util.Iterator<" << type_name(element_type, true, false) + << ">> get" << cap_name; out << get_cap_name("iterator() {") << endl; indent_up(); @@ -2198,13 +2197,13 @@ void t_java_generator::generate_java_bean_boilerplate(ofstream& out, t_struct* t indent_down(); indent(out) << "}" << endl << endl; } else { - indent(out) << "public java.util.Iterator<" << - type_name(element_type, true, false) << "> get" << cap_name; + indent(out) << "public java.util.Iterator<" << type_name(element_type, true, false) + << "> get" << cap_name; out << get_cap_name("iterator() {") << endl; indent_up(); - indent(out) << "return (this." << field_name << " == null) ? null : " << - "this." << field_name << ".iterator();" << endl; + indent(out) << "return (this." << field_name << " == null) ? null : " + << "this." << field_name << ".iterator();" << endl; indent_down(); indent(out) << "}" << endl << endl; } @@ -2264,8 +2263,7 @@ void t_java_generator::generate_java_bean_boilerplate(ofstream& out, t_struct* t } else { if (optional) { indent(out) << "public Option<" << type_name(type, true) << ">"; - if (type->is_base_type() && - ((t_base_type*)type)->get_base() == t_base_type::TYPE_BOOL) { + if (type->is_base_type() && ((t_base_type*)type)->get_base() == t_base_type::TYPE_BOOL) { out << " is"; } else { out << " get"; @@ -2286,8 +2284,7 @@ void t_java_generator::generate_java_bean_boilerplate(ofstream& out, t_struct* t indent(out) << "}" << endl << endl; } else { indent(out) << "public " << type_name(type); - if (type->is_base_type() && - ((t_base_type*)type)->get_base() == t_base_type::TYPE_BOOL) { + if (type->is_base_type() && ((t_base_type*)type)->get_base() == t_base_type::TYPE_BOOL) { out << " is"; } else { out << " get"; @@ -2426,17 +2423,20 @@ void t_java_generator::generate_java_struct_tostring(ofstream& out, t_struct* ts indent_up(); } - if (get_true_type(field->get_type())->is_base_type() && ((t_base_type*)(get_true_type(field->get_type())))->is_binary()) { + if (get_true_type(field->get_type())->is_base_type() + && ((t_base_type*)(get_true_type(field->get_type())))->is_binary()) { indent(out) << "org.apache.thrift.TBaseHelper.toString(this." << field->get_name() << ", sb);" << endl; - } else if ((field->get_type()->is_set()) && - (get_true_type(((t_set*) field->get_type())->get_elem_type())->is_base_type()) && - (((t_base_type*) get_true_type(((t_set*) field->get_type())->get_elem_type()))->is_binary())) { + } else if ((field->get_type()->is_set()) + && (get_true_type(((t_set*)field->get_type())->get_elem_type())->is_base_type()) + && (((t_base_type*)get_true_type(((t_set*)field->get_type())->get_elem_type())) + ->is_binary())) { indent(out) << "org.apache.thrift.TBaseHelper.toString(this." << field->get_name() << ", sb);" << endl; - } else if ((field->get_type()->is_list()) && - (get_true_type(((t_list*) field->get_type())->get_elem_type())->is_base_type()) && - (((t_base_type*) get_true_type(((t_list*) field->get_type())->get_elem_type()))->is_binary())) { + } else if ((field->get_type()->is_list()) + && (get_true_type(((t_list*)field->get_type())->get_elem_type())->is_base_type()) + && (((t_base_type*)get_true_type(((t_list*)field->get_type())->get_elem_type())) + ->is_binary())) { indent(out) << "org.apache.thrift.TBaseHelper.toString(this." << field->get_name() << ", sb);" << endl; } else { @@ -3681,14 +3681,13 @@ void t_java_generator::generate_deserialize_map_element(ofstream& out, indent(out) << prefix << ".put(" << key << ", " << val << ");" << endl; - if ( reuse_objects_ && !get_true_type(fkey.get_type())->is_base_type()) { + if (reuse_objects_ && !get_true_type(fkey.get_type())->is_base_type()) { indent(out) << key << " = null;" << endl; } - if ( reuse_objects_ && !get_true_type(fval.get_type())->is_base_type()) { + if (reuse_objects_ && !get_true_type(fval.get_type())->is_base_type()) { indent(out) << val << " = null;" << endl; } - } /** @@ -3715,10 +3714,9 @@ void t_java_generator::generate_deserialize_set_element(ofstream& out, indent(out) << prefix << ".add(" << elem << ");" << endl; - if ( reuse_objects_ && !get_true_type(felem.get_type())->is_base_type()) { + if (reuse_objects_ && !get_true_type(felem.get_type())->is_base_type()) { indent(out) << elem << " = null;" << endl; } - } /** @@ -3745,10 +3743,9 @@ void t_java_generator::generate_deserialize_list_element(ofstream& out, indent(out) << prefix << ".add(" << elem << ");" << endl; - if ( reuse_objects_ && !get_true_type(felem.get_type())->is_base_type()) { + if (reuse_objects_ && !get_true_type(felem.get_type())->is_base_type()) { indent(out) << elem << " = null;" << endl; } - } /** @@ -4723,7 +4720,7 @@ void t_java_generator::generate_java_struct_clear(std::ofstream& out, t_struct* if (reuse_objects_ && (t->is_container() || t->is_struct())) { indent(out) << "if (this." << field->get_name() << " != null) {" << endl; indent_up(); - indent(out) << "this." << field->get_name() << ".clear();" << endl; + indent(out) << "this." << field->get_name() << ".clear();" << endl; indent_down(); indent(out) << "}" << endl; @@ -5096,10 +5093,8 @@ void t_java_generator::generate_javax_generated_annotation(ofstream& out) { time_t seconds = time(NULL); struct tm* now = localtime(&seconds); indent(out) << "@Generated(value = \"" << autogen_summary() << "\", date = \"" - << (now->tm_year + 1900) - << "-" << setfill('0') << setw(2) << (now->tm_mon + 1) - << "-" << setfill('0') << setw(2) << now->tm_mday << "\")" - << endl; + << (now->tm_year + 1900) << "-" << setfill('0') << setw(2) << (now->tm_mon + 1) << "-" + << setfill('0') << setw(2) << now->tm_mday << "\")" << endl; } THRIFT_REGISTER_GENERATOR( http://git-wip-us.apache.org/repos/asf/thrift/blob/1f6e380c/compiler/cpp/src/generate/t_lua_generator.cc ---------------------------------------------------------------------- diff --git a/compiler/cpp/src/generate/t_lua_generator.cc b/compiler/cpp/src/generate/t_lua_generator.cc index 1b3dac6..3ca8ae0 100644 --- a/compiler/cpp/src/generate/t_lua_generator.cc +++ b/compiler/cpp/src/generate/t_lua_generator.cc @@ -93,11 +93,20 @@ private: /** * Deserialization (Read) */ - void generate_deserialize_field(std::ofstream& out, t_field* tfield, bool local, std::string prefix = ""); + void generate_deserialize_field(std::ofstream& out, + t_field* tfield, + bool local, + std::string prefix = ""); - void generate_deserialize_struct(std::ofstream& out, t_struct* tstruct, bool local, std::string prefix = ""); + void generate_deserialize_struct(std::ofstream& out, + t_struct* tstruct, + bool local, + std::string prefix = ""); - void generate_deserialize_container(std::ofstream& out, t_type* ttype, bool local, std::string prefix = ""); + void generate_deserialize_container(std::ofstream& out, + t_type* ttype, + bool local, + std::string prefix = ""); void generate_deserialize_set_element(std::ofstream& out, t_set* tset, std::string prefix = ""); @@ -747,7 +756,10 @@ void t_lua_generator::generate_function_helpers(ofstream& out, t_function* tfunc /** * Deserialize (Read) */ -void t_lua_generator::generate_deserialize_field(ofstream& out, t_field* tfield, bool local, string prefix) { +void t_lua_generator::generate_deserialize_field(ofstream& out, + t_field* tfield, + bool local, + string prefix) { t_type* type = get_true_type(tfield->get_type()); if (type->is_void()) { @@ -805,12 +817,18 @@ void t_lua_generator::generate_deserialize_field(ofstream& out, t_field* tfield, } } -void t_lua_generator::generate_deserialize_struct(ofstream& out, t_struct* tstruct, bool local, string prefix) { - indent(out) << (local ? "local " : "") << prefix << " = " << tstruct->get_name() << ":new{}" << endl << indent() << prefix - << ":read(iprot)" << endl; +void t_lua_generator::generate_deserialize_struct(ofstream& out, + t_struct* tstruct, + bool local, + string prefix) { + indent(out) << (local ? "local " : "") << prefix << " = " << tstruct->get_name() << ":new{}" + << endl << indent() << prefix << ":read(iprot)" << endl; } -void t_lua_generator::generate_deserialize_container(ofstream& out, t_type* ttype, bool local, string prefix) { +void t_lua_generator::generate_deserialize_container(ofstream& out, + t_type* ttype, + bool local, + string prefix) { string size = tmp("_size"); string ktype = tmp("_ktype"); string vtype = tmp("_vtype"); http://git-wip-us.apache.org/repos/asf/thrift/blob/1f6e380c/compiler/cpp/src/generate/t_rb_generator.cc ---------------------------------------------------------------------- diff --git a/compiler/cpp/src/generate/t_rb_generator.cc b/compiler/cpp/src/generate/t_rb_generator.cc index 9dac54a..b25c248 100644 --- a/compiler/cpp/src/generate/t_rb_generator.cc +++ b/compiler/cpp/src/generate/t_rb_generator.cc @@ -754,11 +754,12 @@ void t_rb_generator::generate_service(t_service* tservice) { if (tservice->get_extends() != NULL) { if (namespaced_) { - f_service_ << "require '" << rb_namespace_to_path_prefix(tservice->get_extends()->get_program()->get_namespace("rb")) << underscore(tservice->get_extends()->get_name()) - << "'" << endl; + f_service_ << "require '" << rb_namespace_to_path_prefix( + tservice->get_extends()->get_program()->get_namespace("rb")) + << underscore(tservice->get_extends()->get_name()) << "'" << endl; } else { - f_service_ << "require '" << require_prefix_ << underscore(tservice->get_extends()->get_name()) - << "'" << endl; + f_service_ << "require '" << require_prefix_ + << underscore(tservice->get_extends()->get_name()) << "'" << endl; } } http://git-wip-us.apache.org/repos/asf/thrift/blob/1f6e380c/compiler/cpp/src/parse/t_enum.h ---------------------------------------------------------------------- diff --git a/compiler/cpp/src/parse/t_enum.h b/compiler/cpp/src/parse/t_enum.h index 12b4ad8..7b6a020 100644 --- a/compiler/cpp/src/parse/t_enum.h +++ b/compiler/cpp/src/parse/t_enum.h @@ -31,7 +31,7 @@ class t_enum : public t_type { public: t_enum(t_program* program) : t_type(program) {} - void set_name(const std::string &name) { name_ = name; } + void set_name(const std::string& name) { name_ = name; } void append(t_enum_value* constant) { constants_.push_back(constant); } http://git-wip-us.apache.org/repos/asf/thrift/blob/1f6e380c/lib/cpp/src/thrift/TOutput.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/TOutput.h b/lib/cpp/src/thrift/TOutput.h index 9053b80..1375f73 100644 --- a/lib/cpp/src/thrift/TOutput.h +++ b/lib/cpp/src/thrift/TOutput.h @@ -52,7 +52,6 @@ private: }; extern TOutput GlobalOutput; - } } // namespace apache::thrift http://git-wip-us.apache.org/repos/asf/thrift/blob/1f6e380c/lib/cpp/src/thrift/protocol/TJSONProtocol.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/protocol/TJSONProtocol.cpp b/lib/cpp/src/thrift/protocol/TJSONProtocol.cpp index 5e1d42b..8d84e4b 100644 --- a/lib/cpp/src/thrift/protocol/TJSONProtocol.cpp +++ b/lib/cpp/src/thrift/protocol/TJSONProtocol.cpp @@ -509,10 +509,8 @@ uint32_t TJSONProtocol::writeJSONInteger(NumberType num) { return result; } -namespace -{ -std::string doubleToString(double d) -{ +namespace { +std::string doubleToString(double d) { std::ostringstream str; str.imbue(std::locale::classic()); str.precision(std::numeric_limits<double>::digits10 + 1); @@ -817,10 +815,8 @@ uint32_t TJSONProtocol::readJSONInteger(NumberType& num) { return result; } -namespace -{ -double stringToDouble(const std::string& s) -{ +namespace { +double stringToDouble(const std::string& s) { double d; std::istringstream str(s); str.imbue(std::locale::classic()); http://git-wip-us.apache.org/repos/asf/thrift/blob/1f6e380c/lib/cpp/src/thrift/server/TConnectedClient.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/server/TConnectedClient.cpp b/lib/cpp/src/thrift/server/TConnectedClient.cpp index 86a81e2..c248e63 100644 --- a/lib/cpp/src/thrift/server/TConnectedClient.cpp +++ b/lib/cpp/src/thrift/server/TConnectedClient.cpp @@ -36,22 +36,24 @@ TConnectedClient::TConnectedClient(const shared_ptr<TProcessor>& processor, const shared_ptr<TProtocol>& outputProtocol, const shared_ptr<TServerEventHandler>& eventHandler, const shared_ptr<TTransport>& client) - + : processor_(processor), inputProtocol_(inputProtocol), outputProtocol_(outputProtocol), eventHandler_(eventHandler), client_(client), - opaqueContext_(0) {} + opaqueContext_(0) { +} -TConnectedClient::~TConnectedClient() {} +TConnectedClient::~TConnectedClient() { +} void TConnectedClient::run() { if (eventHandler_) { opaqueContext_ = eventHandler_->createContext(inputProtocol_, outputProtocol_); } - for (bool done = false; !done; ) { + for (bool done = false; !done;) { if (eventHandler_) { eventHandler_->processContext(opaqueContext_, client_); } @@ -61,27 +63,25 @@ void TConnectedClient::run() { break; } } catch (const TTransportException& ttx) { - switch (ttx.getType()) - { - case TTransportException::TIMED_OUT: - // Receive timeout - continue processing. - continue; - - case TTransportException::END_OF_FILE: - case TTransportException::INTERRUPTED: - // Client disconnected or was interrupted. No logging needed. Done. - done = true; - break; - - default: - { - // All other transport exceptions are logged. - // State of connection is unknown. Done. - string errStr = string("TConnectedClient died: ") + ttx.what(); - GlobalOutput(errStr.c_str()); - done = true; - break; - } + switch (ttx.getType()) { + case TTransportException::TIMED_OUT: + // Receive timeout - continue processing. + continue; + + case TTransportException::END_OF_FILE: + case TTransportException::INTERRUPTED: + // Client disconnected or was interrupted. No logging needed. Done. + done = true; + break; + + default: { + // All other transport exceptions are logged. + // State of connection is unknown. Done. + string errStr = string("TConnectedClient died: ") + ttx.what(); + GlobalOutput(errStr.c_str()); + done = true; + break; + } } } catch (const TException& tex) { string errStr = string("TConnectedClient processing exception: ") + tex.what(); @@ -93,8 +93,7 @@ void TConnectedClient::run() { cleanup(); } -void TConnectedClient::cleanup() -{ +void TConnectedClient::cleanup() { if (eventHandler_) { eventHandler_->deleteContext(opaqueContext_, inputProtocol_, outputProtocol_); } @@ -120,7 +119,6 @@ void TConnectedClient::cleanup() GlobalOutput(errStr.c_str()); } } - } } } // apache::thrift::server http://git-wip-us.apache.org/repos/asf/thrift/blob/1f6e380c/lib/cpp/src/thrift/server/TConnectedClient.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/server/TConnectedClient.h b/lib/cpp/src/thrift/server/TConnectedClient.h index 8931335..3ea065e 100644 --- a/lib/cpp/src/thrift/server/TConnectedClient.h +++ b/lib/cpp/src/thrift/server/TConnectedClient.h @@ -37,74 +37,72 @@ namespace server { * encapsulated here. */ -class TConnectedClient : public apache::thrift::concurrency::Runnable -{ - public: - /** - * Constructor. - * - * @param[in] processor the TProcessor - * @param[in] inputProtocol the input TProtocol - * @param[in] outputProtocol the output TProtocol - * @param[in] eventHandler the server event handler - * @param[in] client the TTransport representing the client - */ - TConnectedClient( - const boost::shared_ptr<apache::thrift::TProcessor>& processor, - const boost::shared_ptr<apache::thrift::protocol::TProtocol>& inputProtocol, - const boost::shared_ptr<apache::thrift::protocol::TProtocol>& outputProtocol, - const boost::shared_ptr<apache::thrift::server::TServerEventHandler>& eventHandler, - const boost::shared_ptr<apache::thrift::transport::TTransport>& client); +class TConnectedClient : public apache::thrift::concurrency::Runnable { +public: + /** + * Constructor. + * + * @param[in] processor the TProcessor + * @param[in] inputProtocol the input TProtocol + * @param[in] outputProtocol the output TProtocol + * @param[in] eventHandler the server event handler + * @param[in] client the TTransport representing the client + */ + TConnectedClient( + const boost::shared_ptr<apache::thrift::TProcessor>& processor, + const boost::shared_ptr<apache::thrift::protocol::TProtocol>& inputProtocol, + const boost::shared_ptr<apache::thrift::protocol::TProtocol>& outputProtocol, + const boost::shared_ptr<apache::thrift::server::TServerEventHandler>& eventHandler, + const boost::shared_ptr<apache::thrift::transport::TTransport>& client); - /** - * Destructor. - */ - virtual ~TConnectedClient(); + /** + * Destructor. + */ + virtual ~TConnectedClient(); - /** - * Drive the client until it is done. - * The client processing loop is: - * - * [optional] call eventHandler->createContext once - * [optional] call eventHandler->processContext per request - * call processor->process per request - * handle expected transport exceptions: - * END_OF_FILE means the client is gone - * INTERRUPTED means the client was interrupted - * by TServerTransport::interruptChildren() - * handle unexpected transport exceptions by logging - * handle standard exceptions by logging - * handle unexpected exceptions by logging - * cleanup() - */ - virtual void run() /* override */; + /** + * Drive the client until it is done. + * The client processing loop is: + * + * [optional] call eventHandler->createContext once + * [optional] call eventHandler->processContext per request + * call processor->process per request + * handle expected transport exceptions: + * END_OF_FILE means the client is gone + * INTERRUPTED means the client was interrupted + * by TServerTransport::interruptChildren() + * handle unexpected transport exceptions by logging + * handle standard exceptions by logging + * handle unexpected exceptions by logging + * cleanup() + */ + virtual void run() /* override */; - protected: - /** - * Cleanup after a client. This happens if the client disconnects, - * or if the server is stopped, or if an exception occurs. - * - * The cleanup processing is: - * [optional] call eventHandler->deleteContext once - * close the inputProtocol's TTransport - * close the outputProtocol's TTransport - * close the client - */ - virtual void cleanup(); +protected: + /** + * Cleanup after a client. This happens if the client disconnects, + * or if the server is stopped, or if an exception occurs. + * + * The cleanup processing is: + * [optional] call eventHandler->deleteContext once + * close the inputProtocol's TTransport + * close the outputProtocol's TTransport + * close the client + */ + virtual void cleanup(); - private: - boost::shared_ptr<apache::thrift::TProcessor> processor_; - boost::shared_ptr<apache::thrift::protocol::TProtocol> inputProtocol_; - boost::shared_ptr<apache::thrift::protocol::TProtocol> outputProtocol_; - boost::shared_ptr<apache::thrift::server::TServerEventHandler> eventHandler_; - boost::shared_ptr<apache::thrift::transport::TTransport> client_; +private: + boost::shared_ptr<apache::thrift::TProcessor> processor_; + boost::shared_ptr<apache::thrift::protocol::TProtocol> inputProtocol_; + boost::shared_ptr<apache::thrift::protocol::TProtocol> outputProtocol_; + boost::shared_ptr<apache::thrift::server::TServerEventHandler> eventHandler_; + boost::shared_ptr<apache::thrift::transport::TTransport> client_; - /** - * Context acquired from the eventHandler_ if one exists. - */ - void *opaqueContext_; + /** + * Context acquired from the eventHandler_ if one exists. + */ + void* opaqueContext_; }; - } } } http://git-wip-us.apache.org/repos/asf/thrift/blob/1f6e380c/lib/cpp/src/thrift/server/TNonblockingServer.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/server/TNonblockingServer.cpp b/lib/cpp/src/thrift/server/TNonblockingServer.cpp index 631c2d5..d1e9ede 100644 --- a/lib/cpp/src/thrift/server/TNonblockingServer.cpp +++ b/lib/cpp/src/thrift/server/TNonblockingServer.cpp @@ -1249,7 +1249,7 @@ void TNonblockingServer::registerEvents(event_base* user_event_base) { */ void TNonblockingServer::serve() { - if(ioThreads_.empty()) + if (ioThreads_.empty()) registerEvents(NULL); // Run the primary (listener) IO thread loop in our main thread; this will @@ -1400,7 +1400,7 @@ bool TNonblockingIOThread::notify(TNonblockingServer::TConnection* conn) { fd_set wfds, efds; int ret = -1; int kSize = sizeof(conn); - const char * pos = (const char *)const_cast_sockopt(&conn); + const char* pos = (const char*)const_cast_sockopt(&conn); while (kSize > 0) { FD_ZERO(&wfds); http://git-wip-us.apache.org/repos/asf/thrift/blob/1f6e380c/lib/cpp/src/thrift/server/TNonblockingServer.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/server/TNonblockingServer.h b/lib/cpp/src/thrift/server/TNonblockingServer.h index 7922a68..aacb492 100644 --- a/lib/cpp/src/thrift/server/TNonblockingServer.h +++ b/lib/cpp/src/thrift/server/TNonblockingServer.h @@ -305,14 +305,12 @@ private: } public: - TNonblockingServer(const boost::shared_ptr<TProcessorFactory>& processorFactory, - int port) + TNonblockingServer(const boost::shared_ptr<TProcessorFactory>& processorFactory, int port) : TServer(processorFactory) { init(port); } - TNonblockingServer(const boost::shared_ptr<TProcessor>& processor, - int port) + TNonblockingServer(const boost::shared_ptr<TProcessor>& processor, int port) : TServer(processor) { init(port); } http://git-wip-us.apache.org/repos/asf/thrift/blob/1f6e380c/lib/cpp/src/thrift/server/TServerFramework.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/server/TServerFramework.cpp b/lib/cpp/src/thrift/server/TServerFramework.cpp index 36dab5b..e843921 100644 --- a/lib/cpp/src/thrift/server/TServerFramework.cpp +++ b/lib/cpp/src/thrift/server/TServerFramework.cpp @@ -37,57 +37,64 @@ using boost::bind; using boost::shared_ptr; using std::string; -TServerFramework::TServerFramework( - const shared_ptr<TProcessorFactory>& processorFactory, - const shared_ptr<TServerTransport>& serverTransport, - const shared_ptr<TTransportFactory>& transportFactory, - const shared_ptr<TProtocolFactory>& protocolFactory) +TServerFramework::TServerFramework(const shared_ptr<TProcessorFactory>& processorFactory, + const shared_ptr<TServerTransport>& serverTransport, + const shared_ptr<TTransportFactory>& transportFactory, + const shared_ptr<TProtocolFactory>& protocolFactory) : TServer(processorFactory, serverTransport, transportFactory, protocolFactory), clients_(0), hwm_(0), - limit_(INT64_MAX) {} + limit_(INT64_MAX) { +} -TServerFramework::TServerFramework( - const shared_ptr<TProcessor>& processor, - const shared_ptr<TServerTransport>& serverTransport, - const shared_ptr<TTransportFactory>& transportFactory, - const shared_ptr<TProtocolFactory>& protocolFactory) +TServerFramework::TServerFramework(const shared_ptr<TProcessor>& processor, + const shared_ptr<TServerTransport>& serverTransport, + const shared_ptr<TTransportFactory>& transportFactory, + const shared_ptr<TProtocolFactory>& protocolFactory) : TServer(processor, serverTransport, transportFactory, protocolFactory), clients_(0), hwm_(0), - limit_(INT64_MAX) {} - -TServerFramework::TServerFramework( - const shared_ptr<TProcessorFactory>& processorFactory, - const shared_ptr<TServerTransport>& serverTransport, - const shared_ptr<TTransportFactory>& inputTransportFactory, - const shared_ptr<TTransportFactory>& outputTransportFactory, - const shared_ptr<TProtocolFactory>& inputProtocolFactory, - const shared_ptr<TProtocolFactory>& outputProtocolFactory) - : TServer(processorFactory, serverTransport, - inputTransportFactory, outputTransportFactory, - inputProtocolFactory, outputProtocolFactory), + limit_(INT64_MAX) { +} + +TServerFramework::TServerFramework(const shared_ptr<TProcessorFactory>& processorFactory, + const shared_ptr<TServerTransport>& serverTransport, + const shared_ptr<TTransportFactory>& inputTransportFactory, + const shared_ptr<TTransportFactory>& outputTransportFactory, + const shared_ptr<TProtocolFactory>& inputProtocolFactory, + const shared_ptr<TProtocolFactory>& outputProtocolFactory) + : TServer(processorFactory, + serverTransport, + inputTransportFactory, + outputTransportFactory, + inputProtocolFactory, + outputProtocolFactory), clients_(0), hwm_(0), - limit_(INT64_MAX) {} - -TServerFramework::TServerFramework( - const shared_ptr<TProcessor>& processor, - const shared_ptr<TServerTransport>& serverTransport, - const shared_ptr<TTransportFactory>& inputTransportFactory, - const shared_ptr<TTransportFactory>& outputTransportFactory, - const shared_ptr<TProtocolFactory>& inputProtocolFactory, - const shared_ptr<TProtocolFactory>& outputProtocolFactory) - : TServer(processor, serverTransport, - inputTransportFactory, outputTransportFactory, - inputProtocolFactory, outputProtocolFactory), + limit_(INT64_MAX) { +} + +TServerFramework::TServerFramework(const shared_ptr<TProcessor>& processor, + const shared_ptr<TServerTransport>& serverTransport, + const shared_ptr<TTransportFactory>& inputTransportFactory, + const shared_ptr<TTransportFactory>& outputTransportFactory, + const shared_ptr<TProtocolFactory>& inputProtocolFactory, + const shared_ptr<TProtocolFactory>& outputProtocolFactory) + : TServer(processor, + serverTransport, + inputTransportFactory, + outputTransportFactory, + inputProtocolFactory, + outputProtocolFactory), clients_(0), hwm_(0), - limit_(INT64_MAX) {} + limit_(INT64_MAX) { +} -TServerFramework::~TServerFramework() {} +TServerFramework::~TServerFramework() { +} -template<typename T> +template <typename T> static void releaseOneDescriptor(const string& name, T& pTransport) { if (pTransport) { try { @@ -130,10 +137,10 @@ void TServerFramework::serve() { // clients allowed, wait for one or more clients to drain before // accepting another. { - Synchronized sync(mon_); - while (clients_ >= limit_) { - mon_.wait(); - } + Synchronized sync(mon_); + while (clients_ >= limit_) { + mon_.wait(); + } } client = serverTransport_->accept(); @@ -143,11 +150,13 @@ void TServerFramework::serve() { inputProtocol = inputProtocolFactory_->getProtocol(inputTransport); outputProtocol = outputProtocolFactory_->getProtocol(outputTransport); - newlyConnectedClient( - shared_ptr<TConnectedClient>( - new TConnectedClient(getProcessor(inputProtocol, outputProtocol, client), - inputProtocol, outputProtocol, eventHandler_, client), - bind(&TServerFramework::disposeConnectedClient, this, _1))); + newlyConnectedClient(shared_ptr<TConnectedClient>( + new TConnectedClient(getProcessor(inputProtocol, outputProtocol, client), + inputProtocol, + outputProtocol, + eventHandler_, + client), + bind(&TServerFramework::disposeConnectedClient, this, _1))); } catch (TTransportException& ttx) { releaseOneDescriptor("inputTransport", inputTransport); @@ -156,8 +165,8 @@ void TServerFramework::serve() { if (ttx.getType() == TTransportException::TIMED_OUT) { // Accept timeout - continue processing. continue; - } else if (ttx.getType() == TTransportException::END_OF_FILE || - ttx.getType() == TTransportException::INTERRUPTED) { + } else if (ttx.getType() == TTransportException::END_OF_FILE + || ttx.getType() == TTransportException::INTERRUPTED) { // Server was interrupted. This only happens when stopping. break; } else { @@ -213,7 +222,7 @@ void TServerFramework::newlyConnectedClient(const boost::shared_ptr<TConnectedCl hwm_ = std::max(hwm_, clients_); } -void TServerFramework::disposeConnectedClient(TConnectedClient *pClient) { +void TServerFramework::disposeConnectedClient(TConnectedClient* pClient) { { // Count a concurrent client removed. Synchronized sync(mon_); @@ -224,8 +233,6 @@ void TServerFramework::disposeConnectedClient(TConnectedClient *pClient) { onClientDisconnected(pClient); delete pClient; } - } } } // apache::thrift::server - http://git-wip-us.apache.org/repos/asf/thrift/blob/1f6e380c/lib/cpp/src/thrift/server/TServerFramework.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/server/TServerFramework.h b/lib/cpp/src/thrift/server/TServerFramework.h index 3f16dd1..a22688a 100644 --- a/lib/cpp/src/thrift/server/TServerFramework.h +++ b/lib/cpp/src/thrift/server/TServerFramework.h @@ -48,32 +48,32 @@ namespace server { class TServerFramework : public TServer { public: TServerFramework( - const boost::shared_ptr<apache::thrift::TProcessorFactory>& processorFactory, - const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, - const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& transportFactory, - const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& protocolFactory); + const boost::shared_ptr<apache::thrift::TProcessorFactory>& processorFactory, + const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, + const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& transportFactory, + const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& protocolFactory); TServerFramework( - const boost::shared_ptr<apache::thrift::TProcessor>& processor, - const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, - const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& transportFactory, - const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& protocolFactory); + const boost::shared_ptr<apache::thrift::TProcessor>& processor, + const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, + const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& transportFactory, + const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& protocolFactory); TServerFramework( - const boost::shared_ptr<apache::thrift::TProcessorFactory>& processorFactory, - const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, - const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& inputTransportFactory, - const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& outputTransportFactory, - const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory, - const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory); + const boost::shared_ptr<apache::thrift::TProcessorFactory>& processorFactory, + const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, + const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& inputTransportFactory, + const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& outputTransportFactory, + const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory, + const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory); TServerFramework( - const boost::shared_ptr<apache::thrift::TProcessor>& processor, - const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, - const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& inputTransportFactory, - const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& outputTransportFactory, - const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory, - const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory); + const boost::shared_ptr<apache::thrift::TProcessor>& processor, + const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, + const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& inputTransportFactory, + const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& outputTransportFactory, + const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory, + const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory); virtual ~TServerFramework(); @@ -140,7 +140,7 @@ protected: * * \param[in] pClient the disconnected client */ - virtual void onClientDisconnected(TConnectedClient *pClient) = 0; + virtual void onClientDisconnected(TConnectedClient* pClient) = 0; private: /** @@ -154,7 +154,7 @@ private: * Smart pointer client deletion. * Calls onClientDisconnected and then deletes pClient. */ - void disposeConnectedClient(TConnectedClient *pClient); + void disposeConnectedClient(TConnectedClient* pClient); /** * Monitor for limiting the number of concurrent clients. @@ -176,7 +176,6 @@ private: */ int64_t limit_; }; - } } } // apache::thrift::server http://git-wip-us.apache.org/repos/asf/thrift/blob/1f6e380c/lib/cpp/src/thrift/server/TSimpleServer.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/server/TSimpleServer.cpp b/lib/cpp/src/thrift/server/TSimpleServer.cpp index 3b04f35..2f69ff4 100644 --- a/lib/cpp/src/thrift/server/TSimpleServer.cpp +++ b/lib/cpp/src/thrift/server/TSimpleServer.cpp @@ -32,53 +32,54 @@ using apache::thrift::transport::TTransportFactory; using boost::shared_ptr; using std::string; -TSimpleServer::TSimpleServer( - const shared_ptr<TProcessorFactory>& processorFactory, - const shared_ptr<TServerTransport>& serverTransport, - const shared_ptr<TTransportFactory>& transportFactory, - const shared_ptr<TProtocolFactory>& protocolFactory) - : TServerFramework(processorFactory, serverTransport, - transportFactory, protocolFactory) { +TSimpleServer::TSimpleServer(const shared_ptr<TProcessorFactory>& processorFactory, + const shared_ptr<TServerTransport>& serverTransport, + const shared_ptr<TTransportFactory>& transportFactory, + const shared_ptr<TProtocolFactory>& protocolFactory) + : TServerFramework(processorFactory, serverTransport, transportFactory, protocolFactory) { TServerFramework::setConcurrentClientLimit(1); } -TSimpleServer::TSimpleServer( - const shared_ptr<TProcessor>& processor, - const shared_ptr<TServerTransport>& serverTransport, - const shared_ptr<TTransportFactory>& transportFactory, - const shared_ptr<TProtocolFactory>& protocolFactory) - : TServerFramework(processor, serverTransport, - transportFactory, protocolFactory) { +TSimpleServer::TSimpleServer(const shared_ptr<TProcessor>& processor, + const shared_ptr<TServerTransport>& serverTransport, + const shared_ptr<TTransportFactory>& transportFactory, + const shared_ptr<TProtocolFactory>& protocolFactory) + : TServerFramework(processor, serverTransport, transportFactory, protocolFactory) { TServerFramework::setConcurrentClientLimit(1); } -TSimpleServer::TSimpleServer( - const shared_ptr<TProcessorFactory>& processorFactory, - const shared_ptr<TServerTransport>& serverTransport, - const shared_ptr<TTransportFactory>& inputTransportFactory, - const shared_ptr<TTransportFactory>& outputTransportFactory, - const shared_ptr<TProtocolFactory>& inputProtocolFactory, - const shared_ptr<TProtocolFactory>& outputProtocolFactory) - : TServerFramework(processorFactory, serverTransport, - inputTransportFactory, outputTransportFactory, - inputProtocolFactory, outputProtocolFactory) { +TSimpleServer::TSimpleServer(const shared_ptr<TProcessorFactory>& processorFactory, + const shared_ptr<TServerTransport>& serverTransport, + const shared_ptr<TTransportFactory>& inputTransportFactory, + const shared_ptr<TTransportFactory>& outputTransportFactory, + const shared_ptr<TProtocolFactory>& inputProtocolFactory, + const shared_ptr<TProtocolFactory>& outputProtocolFactory) + : TServerFramework(processorFactory, + serverTransport, + inputTransportFactory, + outputTransportFactory, + inputProtocolFactory, + outputProtocolFactory) { TServerFramework::setConcurrentClientLimit(1); } -TSimpleServer::TSimpleServer( - const shared_ptr<TProcessor>& processor, - const shared_ptr<TServerTransport>& serverTransport, - const shared_ptr<TTransportFactory>& inputTransportFactory, - const shared_ptr<TTransportFactory>& outputTransportFactory, - const shared_ptr<TProtocolFactory>& inputProtocolFactory, - const shared_ptr<TProtocolFactory>& outputProtocolFactory) - : TServerFramework(processor, serverTransport, - inputTransportFactory, outputTransportFactory, - inputProtocolFactory, outputProtocolFactory) { +TSimpleServer::TSimpleServer(const shared_ptr<TProcessor>& processor, + const shared_ptr<TServerTransport>& serverTransport, + const shared_ptr<TTransportFactory>& inputTransportFactory, + const shared_ptr<TTransportFactory>& outputTransportFactory, + const shared_ptr<TProtocolFactory>& inputProtocolFactory, + const shared_ptr<TProtocolFactory>& outputProtocolFactory) + : TServerFramework(processor, + serverTransport, + inputTransportFactory, + outputTransportFactory, + inputProtocolFactory, + outputProtocolFactory) { TServerFramework::setConcurrentClientLimit(1); } -TSimpleServer::~TSimpleServer() {} +TSimpleServer::~TSimpleServer() { +} /** * The main body of customized implementation for TSimpleServer is quite simple: @@ -92,15 +93,15 @@ void TSimpleServer::onClientConnected(const shared_ptr<TConnectedClient>& pClien /** * TSimpleServer does not track clients so there is nothing to do here. */ -void TSimpleServer::onClientDisconnected(TConnectedClient*) {} +void TSimpleServer::onClientDisconnected(TConnectedClient*) { +} /** * This makes little sense to the simple server because it is not capable * of having more than one client at a time, so we hide it. */ -void TSimpleServer::setConcurrentClientLimit(int64_t) {} - - +void TSimpleServer::setConcurrentClientLimit(int64_t) { +} } } } // apache::thrift::server http://git-wip-us.apache.org/repos/asf/thrift/blob/1f6e380c/lib/cpp/src/thrift/server/TSimpleServer.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/server/TSimpleServer.h b/lib/cpp/src/thrift/server/TSimpleServer.h index 30d5046..391fbec 100644 --- a/lib/cpp/src/thrift/server/TSimpleServer.h +++ b/lib/cpp/src/thrift/server/TSimpleServer.h @@ -33,40 +33,43 @@ namespace server { */ class TSimpleServer : public TServerFramework { public: - TSimpleServer(const boost::shared_ptr<apache::thrift::TProcessorFactory>& processorFactory, - const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, - const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& transportFactory, - const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& protocolFactory); + TSimpleServer( + const boost::shared_ptr<apache::thrift::TProcessorFactory>& processorFactory, + const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, + const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& transportFactory, + const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& protocolFactory); - TSimpleServer(const boost::shared_ptr<apache::thrift::TProcessor>& processor, - const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, - const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& transportFactory, - const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& protocolFactory); + TSimpleServer( + const boost::shared_ptr<apache::thrift::TProcessor>& processor, + const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, + const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& transportFactory, + const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& protocolFactory); - TSimpleServer(const boost::shared_ptr<apache::thrift::TProcessorFactory>& processorFactory, - const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, - const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& inputTransportFactory, - const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& outputTransportFactory, - const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory, - const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory); + TSimpleServer( + const boost::shared_ptr<apache::thrift::TProcessorFactory>& processorFactory, + const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, + const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& inputTransportFactory, + const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& outputTransportFactory, + const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory, + const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory); - TSimpleServer(const boost::shared_ptr<apache::thrift::TProcessor>& processor, - const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, - const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& inputTransportFactory, - const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& outputTransportFactory, - const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory, - const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory); + TSimpleServer( + const boost::shared_ptr<apache::thrift::TProcessor>& processor, + const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, + const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& inputTransportFactory, + const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& outputTransportFactory, + const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory, + const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory); virtual ~TSimpleServer(); protected: virtual void onClientConnected(const boost::shared_ptr<TConnectedClient>& pClient) /* override */; - virtual void onClientDisconnected(TConnectedClient *pClient) /* override */; + virtual void onClientDisconnected(TConnectedClient* pClient) /* override */; private: - void setConcurrentClientLimit(int64_t newLimit); // hide + void setConcurrentClientLimit(int64_t newLimit); // hide }; - } } } // apache::thrift::server http://git-wip-us.apache.org/repos/asf/thrift/blob/1f6e380c/lib/cpp/src/thrift/server/TThreadPoolServer.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/server/TThreadPoolServer.cpp b/lib/cpp/src/thrift/server/TThreadPoolServer.cpp index 60634ef..efd7c23 100644 --- a/lib/cpp/src/thrift/server/TThreadPoolServer.cpp +++ b/lib/cpp/src/thrift/server/TThreadPoolServer.cpp @@ -33,63 +33,68 @@ using apache::thrift::transport::TTransportFactory; using boost::shared_ptr; using std::string; -TThreadPoolServer::TThreadPoolServer( - const shared_ptr<TProcessorFactory>& processorFactory, - const shared_ptr<TServerTransport>& serverTransport, - const shared_ptr<TTransportFactory>& transportFactory, - const shared_ptr<TProtocolFactory>& protocolFactory, - const shared_ptr<ThreadManager>& threadManager) - : TServerFramework(processorFactory, serverTransport, - transportFactory, protocolFactory), +TThreadPoolServer::TThreadPoolServer(const shared_ptr<TProcessorFactory>& processorFactory, + const shared_ptr<TServerTransport>& serverTransport, + const shared_ptr<TTransportFactory>& transportFactory, + const shared_ptr<TProtocolFactory>& protocolFactory, + const shared_ptr<ThreadManager>& threadManager) + : TServerFramework(processorFactory, serverTransport, transportFactory, protocolFactory), threadManager_(threadManager), timeout_(0), - taskExpiration_(0) {} - -TThreadPoolServer::TThreadPoolServer( - const shared_ptr<TProcessor>& processor, - const shared_ptr<TServerTransport>& serverTransport, - const shared_ptr<TTransportFactory>& transportFactory, - const shared_ptr<TProtocolFactory>& protocolFactory, - const shared_ptr<ThreadManager>& threadManager) - : TServerFramework(processor, serverTransport, - transportFactory, protocolFactory), + taskExpiration_(0) { +} + +TThreadPoolServer::TThreadPoolServer(const shared_ptr<TProcessor>& processor, + const shared_ptr<TServerTransport>& serverTransport, + const shared_ptr<TTransportFactory>& transportFactory, + const shared_ptr<TProtocolFactory>& protocolFactory, + const shared_ptr<ThreadManager>& threadManager) + : TServerFramework(processor, serverTransport, transportFactory, protocolFactory), threadManager_(threadManager), timeout_(0), - taskExpiration_(0) {} - -TThreadPoolServer::TThreadPoolServer( - const shared_ptr<TProcessorFactory>& processorFactory, - const shared_ptr<TServerTransport>& serverTransport, - const shared_ptr<TTransportFactory>& inputTransportFactory, - const shared_ptr<TTransportFactory>& outputTransportFactory, - const shared_ptr<TProtocolFactory>& inputProtocolFactory, - const shared_ptr<TProtocolFactory>& outputProtocolFactory, - const shared_ptr<ThreadManager>& threadManager) - : TServerFramework(processorFactory, serverTransport, - inputTransportFactory, outputTransportFactory, - inputProtocolFactory, outputProtocolFactory), + taskExpiration_(0) { +} + +TThreadPoolServer::TThreadPoolServer(const shared_ptr<TProcessorFactory>& processorFactory, + const shared_ptr<TServerTransport>& serverTransport, + const shared_ptr<TTransportFactory>& inputTransportFactory, + const shared_ptr<TTransportFactory>& outputTransportFactory, + const shared_ptr<TProtocolFactory>& inputProtocolFactory, + const shared_ptr<TProtocolFactory>& outputProtocolFactory, + const shared_ptr<ThreadManager>& threadManager) + : TServerFramework(processorFactory, + serverTransport, + inputTransportFactory, + outputTransportFactory, + inputProtocolFactory, + outputProtocolFactory), threadManager_(threadManager), stop_(false), timeout_(0), - taskExpiration_(0) {} - -TThreadPoolServer::TThreadPoolServer( - const shared_ptr<TProcessor>& processor, - const shared_ptr<TServerTransport>& serverTransport, - const shared_ptr<TTransportFactory>& inputTransportFactory, - const shared_ptr<TTransportFactory>& outputTransportFactory, - const shared_ptr<TProtocolFactory>& inputProtocolFactory, - const shared_ptr<TProtocolFactory>& outputProtocolFactory, - const shared_ptr<ThreadManager>& threadManager) - : TServerFramework(processor, serverTransport, - inputTransportFactory, outputTransportFactory, - inputProtocolFactory, outputProtocolFactory), + taskExpiration_(0) { +} + +TThreadPoolServer::TThreadPoolServer(const shared_ptr<TProcessor>& processor, + const shared_ptr<TServerTransport>& serverTransport, + const shared_ptr<TTransportFactory>& inputTransportFactory, + const shared_ptr<TTransportFactory>& outputTransportFactory, + const shared_ptr<TProtocolFactory>& inputProtocolFactory, + const shared_ptr<TProtocolFactory>& outputProtocolFactory, + const shared_ptr<ThreadManager>& threadManager) + : TServerFramework(processor, + serverTransport, + inputTransportFactory, + outputTransportFactory, + inputProtocolFactory, + outputProtocolFactory), threadManager_(threadManager), stop_(false), timeout_(0), - taskExpiration_(0) {} + taskExpiration_(0) { +} -TThreadPoolServer::~TThreadPoolServer() {} +TThreadPoolServer::~TThreadPoolServer() { +} void TThreadPoolServer::serve() { TServerFramework::serve(); @@ -112,7 +117,8 @@ void TThreadPoolServer::setTaskExpiration(int64_t value) { taskExpiration_ = value; } -boost::shared_ptr<apache::thrift::concurrency::ThreadManager> TThreadPoolServer::getThreadManager() const { +boost::shared_ptr<apache::thrift::concurrency::ThreadManager> TThreadPoolServer::getThreadManager() + const { return threadManager_; } @@ -120,8 +126,8 @@ void TThreadPoolServer::onClientConnected(const shared_ptr<TConnectedClient>& pC threadManager_->add(pClient, timeout_, taskExpiration_); } -void TThreadPoolServer::onClientDisconnected(TConnectedClient*) {} - +void TThreadPoolServer::onClientDisconnected(TConnectedClient*) { +} } } } // apache::thrift::server
