From: David Reiss Date: Wed, 11 Jun 2008 00:57:35 +0000 (+0000) Subject: Implement async_void in alterl bindings X-Git-Tag: 0.2.0~746 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=cdf8d1994a4fb39029964af0d4dc4a636029ab92;p=common%2Fthrift.git Implement async_void in alterl bindings Summary: - reply_type for async void functions is now async_void instead of the empty struct definition - async void functions should return "ok". otherwise the processor will crash and the connection will be killed. Is this behaviour expected? Test Plan: tested using testAsync() in ThriftTest. Didn't used to work but works now git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@666415 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/compiler/cpp/src/generate/t_alterl_generator.cc b/compiler/cpp/src/generate/t_alterl_generator.cc index cb4c1af0..f3d661fb 100644 --- a/compiler/cpp/src/generate/t_alterl_generator.cc +++ b/compiler/cpp/src/generate/t_alterl_generator.cc @@ -527,6 +527,8 @@ void t_alterl_generator::generate_function_info(t_service* tservice, if (!tfunction->get_returntype()->is_void()) indent(f_service_) << generate_type_term(tfunction->get_returntype(), true) << ";" << endl; + else if (tfunction->is_async()) + indent(f_service_) << "async_void;" << endl; else indent(f_service_) << "{struct, []}" << ";" << endl; indent_down(); @@ -537,13 +539,6 @@ void t_alterl_generator::generate_function_info(t_service* tservice, indent_up(); indent(f_service_) << generate_type_term(xs, true) << ";" << endl; indent_down(); - - // function_info(Function, is_async): - indent(f_service_) << - "function_info(" << name_atom << ", is_async) -> "; - - f_service_ << ((tfunction->is_async()) ? "true" : "false"); - f_service_ << ";" << endl; } diff --git a/lib/alterl/src/thrift_processor.erl b/lib/alterl/src/thrift_processor.erl index c3434cd3..2b435acb 100644 --- a/lib/alterl/src/thrift_processor.erl +++ b/lib/alterl/src/thrift_processor.erl @@ -73,7 +73,11 @@ handle_success(State = #state{out_protocol = OProto, ok = send_reply(OProto, Function, ?tMessageType_REPLY, Reply); ok when ReplyType == {struct, []} -> - ok = send_reply(OProto, Function, ?tMessageType_REPLY, {ReplyType, {StructName}}) + ok = send_reply(OProto, Function, ?tMessageType_REPLY, {ReplyType, {StructName}}); + + ok when ReplyType == async_void -> + % no reply for async void + ok end, ok. diff --git a/test/erl/src/test_server.erl b/test/erl/src/test_server.erl index 1bd0e1c3..d44e9021 100644 --- a/test/erl/src/test_server.erl +++ b/test/erl/src/test_server.erl @@ -148,4 +148,8 @@ handle_function(testMultiException, {Arg0, Arg1}) -> #xtruct{string_thing = "This is an Xception2"}}); _ -> {reply, #xtruct{string_thing = Arg1}} - end. + end; + +handle_function(testAsync, {Seconds}) -> + timer:sleep(1000 * Seconds), + ok.