private async Task RunAsync() { string host = "0.0.0.0"; int port = options.DriverPort; var tcs = new TaskCompletionSource<object>(); var workerServiceImpl = new WorkerServiceImpl(() => { Task.Run(() => tcs.SetResult(null)); }); var server = new Server { Services = { WorkerService.BindService(workerServiceImpl) }, Ports = { new ServerPort(host, options.DriverPort, ServerCredentials.Insecure )} }; int boundPort = server.Ports.Single().BoundPort; Console.WriteLine("Running qps worker server on " + string.Format("{0}:{1}", host, boundPort)); server.Start(); await tcs.Task; await server.ShutdownAsync(); }
private async Task RunAsync() { // (ThreadPoolSize == ProcessorCount) gives best throughput in benchmarks // and doesn't seem to harm performance even when server and client // are running on the same machine. GrpcEnvironment.SetThreadPoolSize(Environment.ProcessorCount); string host = "0.0.0.0"; int port = options.DriverPort; var tcs = new TaskCompletionSource<object>(); var workerServiceImpl = new WorkerServiceImpl(() => { Task.Run(() => tcs.SetResult(null)); }); var server = new Server { Services = { WorkerService.BindService(workerServiceImpl) }, Ports = { new ServerPort(host, options.DriverPort, ServerCredentials.Insecure )} }; int boundPort = server.Ports.Single().BoundPort; Console.WriteLine("Running qps worker server on " + string.Format("{0}:{1}", host, boundPort)); server.Start(); await tcs.Task; await server.ShutdownAsync(); }