Author: dreiss
Date: Tue Jun 10 17:57:35 2008
New Revision: 666415
URL: http://svn.apache.org/viewvc?rev=666415&view=rev
Log:
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
Modified:
incubator/thrift/trunk/compiler/cpp/src/generate/t_alterl_generator.cc
incubator/thrift/trunk/lib/alterl/src/thrift_processor.erl
incubator/thrift/trunk/test/erl/src/test_server.erl
Modified: incubator/thrift/trunk/compiler/cpp/src/generate/t_alterl_generator.cc
URL:
http://svn.apache.org/viewvc/incubator/thrift/trunk/compiler/cpp/src/generate/t_alterl_generator.cc?rev=666415&r1=666414&r2=666415&view=diff
==============================================================================
--- incubator/thrift/trunk/compiler/cpp/src/generate/t_alterl_generator.cc
(original)
+++ incubator/thrift/trunk/compiler/cpp/src/generate/t_alterl_generator.cc Tue
Jun 10 17:57:35 2008
@@ -527,6 +527,8 @@
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 @@
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;
}
Modified: incubator/thrift/trunk/lib/alterl/src/thrift_processor.erl
URL:
http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/alterl/src/thrift_processor.erl?rev=666415&r1=666414&r2=666415&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/alterl/src/thrift_processor.erl (original)
+++ incubator/thrift/trunk/lib/alterl/src/thrift_processor.erl Tue Jun 10
17:57:35 2008
@@ -73,7 +73,11 @@
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.
Modified: incubator/thrift/trunk/test/erl/src/test_server.erl
URL:
http://svn.apache.org/viewvc/incubator/thrift/trunk/test/erl/src/test_server.erl?rev=666415&r1=666414&r2=666415&view=diff
==============================================================================
--- incubator/thrift/trunk/test/erl/src/test_server.erl (original)
+++ incubator/thrift/trunk/test/erl/src/test_server.erl Tue Jun 10 17:57:35 2008
@@ -148,4 +148,8 @@
#xtruct{string_thing = "This is an
Xception2"}});
_ ->
{reply, #xtruct{string_thing = Arg1}}
- end.
+ end;
+
+handle_function(testAsync, {Seconds}) ->
+ timer:sleep(1000 * Seconds),
+ ok.