Account for time difference in mac and linux

pull/1948/head
Vijay Pai 10 years ago
parent 8559485c23
commit 9dc5c15b56
  1. 2
      include/grpc++/time.h
  2. 2
      src/cpp/util/time.cc
  3. 4
      test/cpp/qps/client.h
  4. 3
      test/cpp/qps/client_async.cc

@ -85,7 +85,7 @@ namespace grpc {
// from and to should be absolute time.
void Timepoint2Timespec(const std::chrono::system_clock::time_point& from,
gpr_timespec* to);
void Timepoint2Timespec(const std::chrono::high_resolution_clock::time_point& from,
void TimepointHR2Timespec(const std::chrono::high_resolution_clock::time_point& from,
gpr_timespec* to);
std::chrono::system_clock::time_point Timespec2Timepoint(gpr_timespec t);

@ -60,7 +60,7 @@ void Timepoint2Timespec(const system_clock::time_point& from,
to->tv_nsec = nsecs.count();
}
void Timepoint2Timespec(const high_resolution_clock::time_point& from,
void TimepointHR2Timespec(const high_resolution_clock::time_point& from,
gpr_timespec* to) {
high_resolution_clock::duration deadline = from.time_since_epoch();
seconds secs = duration_cast<seconds>(deadline);

@ -44,17 +44,19 @@
namespace grpc {
#if defined(__APPLE__)
// Specialize Timepoint for high res clock as we need that
template <>
class TimePoint<std::chrono::high_resolution_clock::time_point> {
public:
TimePoint(const std::chrono::high_resolution_clock::time_point& time) {
Timepoint2Timespec(time, &time_);
TimepointHR2Timespec(time, &time_);
}
gpr_timespec raw_time() const { return time_; }
private:
gpr_timespec time_;
};
#endif
namespace testing {

@ -215,6 +215,9 @@ class AsyncClient : public Client {
case CompletionQueue::GOT_EVENT:
got_event = true;
break;
default:
GPR_ASSERT(false);
break;
}
if (grpc_time_source::now() > deadline) {
// we have missed some 1-second deadline, which is too much gpr_log(GPR_INFO, "Missed an RPC deadline, giving up");

Loading…
Cancel
Save