Explorar o código

Add note to gpr_convert_clock_type

Esun Kim %!s(int64=5) %!d(string=hai) anos
pai
achega
657275fbc0
Modificáronse 1 ficheiros con 4 adicións e 0 borrados
  1. 4 0
      src/core/lib/gpr/time.cc

+ 4 - 0
src/core/lib/gpr/time.cc

@@ -254,6 +254,10 @@ gpr_timespec gpr_convert_clock_type(gpr_timespec t, gpr_clock_type clock_type) {
     return gpr_time_add(gpr_now(clock_type), t);
     return gpr_time_add(gpr_now(clock_type), t);
   }
   }
 
 
+  // If the given input hits this code, the same result is not guaranteed for
+  // the same input because it relies on `gpr_now` to calculate the difference
+  // between two different clocks. Please be careful when you want to use this
+  // function in unit tests. (e.g. https://github.com/grpc/grpc/pull/22655)
   return gpr_time_add(gpr_now(clock_type),
   return gpr_time_add(gpr_now(clock_type),
                       gpr_time_sub(t, gpr_now(t.clock_type)));
                       gpr_time_sub(t, gpr_now(t.clock_type)));
 }
 }