Skip to content
Snippets Groups Projects
Commit 607307d0 authored by Jan Tattermusch's avatar Jan Tattermusch
Browse files

Cleanup of AsyncCall.cs

parent a96afb01
No related branches found
No related tags found
No related merge requests found
...@@ -64,6 +64,15 @@ namespace math.Tests ...@@ -64,6 +64,15 @@ namespace math.Tests
client = MathGrpc.NewStub(channel); client = MathGrpc.NewStub(channel);
} }
[TestFixtureTearDown]
public void Cleanup()
{
channel.Dispose();
server.ShutdownAsync().Wait();
GrpcEnvironment.Shutdown();
}
[Test] [Test]
public void Div1() public void Div1()
{ {
...@@ -136,15 +145,6 @@ namespace math.Tests ...@@ -136,15 +145,6 @@ namespace math.Tests
CollectionAssert.AreEqual(new long[] {3, 4, 3}, result.ConvertAll((divReply) => divReply.Quotient)); CollectionAssert.AreEqual(new long[] {3, 4, 3}, result.ConvertAll((divReply) => divReply.Quotient));
CollectionAssert.AreEqual(new long[] {1, 16, 1}, result.ConvertAll((divReply) => divReply.Remainder)); CollectionAssert.AreEqual(new long[] {1, 16, 1}, result.ConvertAll((divReply) => divReply.Remainder));
} }
[TestFixtureTearDown]
public void Cleanup()
{
channel.Dispose();
server.ShutdownAsync().Wait();
GrpcEnvironment.Shutdown();
}
} }
} }
...@@ -42,7 +42,7 @@ namespace Google.GRPC.Core ...@@ -42,7 +42,7 @@ namespace Google.GRPC.Core
/// </summary> /// </summary>
public class GrpcEnvironment public class GrpcEnvironment
{ {
const int THREAD_POOL_SIZE = 1; const int THREAD_POOL_SIZE = 4;
[DllImport("grpc_csharp_ext.dll")] [DllImport("grpc_csharp_ext.dll")]
static extern void grpcsharp_init(); static extern void grpcsharp_init();
......
This diff is collapsed.
...@@ -60,7 +60,7 @@ namespace Google.GRPC.Core ...@@ -60,7 +60,7 @@ namespace Google.GRPC.Core
asyncCall.InitializeServer(call); asyncCall.InitializeServer(call);
var finishedTask = asyncCall.StartServerSide(); var finishedTask = asyncCall.ServerSideUnaryRequestCallAsync();
var request = asyncCall.ReceiveMessageAsync().Result; var request = asyncCall.ReceiveMessageAsync().Result;
...@@ -91,14 +91,9 @@ namespace Google.GRPC.Core ...@@ -91,14 +91,9 @@ namespace Google.GRPC.Core
asyncCall.InitializeServer(call); asyncCall.InitializeServer(call);
var finishedTask = asyncCall.StartServerSide();
var responseObserver = new ServerStreamingOutputObserver<TResponse, TRequest>(asyncCall); var responseObserver = new ServerStreamingOutputObserver<TResponse, TRequest>(asyncCall);
var requestObserver = handler(responseObserver); var requestObserver = handler(responseObserver);
var finishedTask = asyncCall.ServerSideStreamingRequestCallAsync(requestObserver);
// feed the requests
asyncCall.StartReadingToStream(requestObserver);
finishedTask.Wait(); finishedTask.Wait();
} }
} }
...@@ -114,7 +109,7 @@ namespace Google.GRPC.Core ...@@ -114,7 +109,7 @@ namespace Google.GRPC.Core
asyncCall.InitializeServer(call); asyncCall.InitializeServer(call);
var finishedTask = asyncCall.StartServerSide(); var finishedTask = asyncCall.ServerSideUnaryRequestCallAsync();
asyncCall.SendStatusFromServerAsync(new Status(StatusCode.GRPC_STATUS_UNIMPLEMENTED, "No such method.")).Wait(); asyncCall.SendStatusFromServerAsync(new Status(StatusCode.GRPC_STATUS_UNIMPLEMENTED, "No such method.")).Wait();
......
...@@ -52,11 +52,21 @@ namespace Google.GRPC.Core.Tests ...@@ -52,11 +52,21 @@ namespace Google.GRPC.Core.Tests
Marshallers.StringMarshaller, Marshallers.StringMarshaller,
Marshallers.StringMarshaller); Marshallers.StringMarshaller);
[Test] [TestFixtureSetUp]
public void UnaryCall() public void Init()
{
GrpcEnvironment.Initialize();
}
[TestFixtureTearDown]
public void Cleanup()
{ {
GrpcEnvironment.Initialize(); GrpcEnvironment.Initialize();
}
[Test]
public void UnaryCall()
{
Server server = new Server(); Server server = new Server();
server.AddServiceDefinition( server.AddServiceDefinition(
ServerServiceDefinition.CreateBuilder("someService") ServerServiceDefinition.CreateBuilder("someService")
...@@ -82,8 +92,6 @@ namespace Google.GRPC.Core.Tests ...@@ -82,8 +92,6 @@ namespace Google.GRPC.Core.Tests
[Test] [Test]
public void UnaryCallPerformance() public void UnaryCallPerformance()
{ {
GrpcEnvironment.Initialize();
Server server = new Server(); Server server = new Server();
server.AddServiceDefinition( server.AddServiceDefinition(
ServerServiceDefinition.CreateBuilder("someService") ServerServiceDefinition.CreateBuilder("someService")
...@@ -107,16 +115,11 @@ namespace Google.GRPC.Core.Tests ...@@ -107,16 +115,11 @@ namespace Google.GRPC.Core.Tests
} }
server.ShutdownAsync().Wait(); server.ShutdownAsync().Wait();
GrpcEnvironment.Shutdown();
} }
[Test] [Test]
public void UnknownMethodHandler() public void UnknownMethodHandler()
{ {
GrpcEnvironment.Initialize();
Server server = new Server(); Server server = new Server();
server.AddServiceDefinition( server.AddServiceDefinition(
ServerServiceDefinition.CreateBuilder("someService").Build()); ServerServiceDefinition.CreateBuilder("someService").Build());
...@@ -137,8 +140,6 @@ namespace Google.GRPC.Core.Tests ...@@ -137,8 +140,6 @@ namespace Google.GRPC.Core.Tests
} }
server.ShutdownAsync().Wait(); server.ShutdownAsync().Wait();
GrpcEnvironment.Shutdown();
} }
private void HandleUnaryEchoString(string request, IObserver<string> responseObserver) { private void HandleUnaryEchoString(string request, IObserver<string> responseObserver) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment