Account for time difference in mac and linux

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

@ -46,7 +46,7 @@
#define GRPC_CXX0X_NO_OVERRIDE 1
#define GRPC_CXX0X_NO_CHRONO 1
#define GRPC_CXX0X_NO_THREAD 1
#endif
#endif
#endif // Visual Studio
#ifndef __clang__

@ -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 {
// Specialize Timepoint for high res clock as we need that
#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 {

@ -204,7 +204,7 @@ class AsyncClient : public Client {
short_deadline = issue_allowed_[thread_idx] ?
next_issue_[thread_idx] : deadline;
}
bool got_event;
switch (cli_cqs_[thread_idx]->AsyncNext(&got_tag, &ok, short_deadline)) {
@ -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