Merge pull request #6858 from makdharma/issue5851

implement interval_us functionality
pull/6949/head
Jan Tattermusch 9 years ago committed by GitHub
commit ef03e53938
  1. 16
      test/cpp/interop/server_main.cc

@ -181,6 +181,14 @@ class TestServiceImpl : public TestService::Service {
response.mutable_payload())) {
return Status(grpc::StatusCode::INTERNAL, "Error creating payload.");
}
int time_us;
if ((time_us = request->response_parameters(i).interval_us()) > 0) {
// Sleep before response if needed
gpr_timespec sleep_time =
gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
gpr_time_from_micros(time_us, GPR_TIMESPAN));
gpr_sleep_until(sleep_time);
}
write_success = writer->Write(response);
}
if (write_success) {
@ -218,6 +226,14 @@ class TestServiceImpl : public TestService::Service {
response.mutable_payload()->set_type(request.payload().type());
response.mutable_payload()->set_body(
grpc::string(request.response_parameters(0).size(), '\0'));
int time_us;
if ((time_us = request.response_parameters(0).interval_us()) > 0) {
// Sleep before response if needed
gpr_timespec sleep_time =
gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
gpr_time_from_micros(time_us, GPR_TIMESPAN));
gpr_sleep_until(sleep_time);
}
write_success = stream->Write(response);
}
}

Loading…
Cancel
Save