aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/csharp/Grpc.Core/Internal
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2015-07-17 22:59:53 -0700
committerGravatar Craig Tiller <ctiller@google.com>2015-07-17 22:59:53 -0700
commitb5980be9a08678212e5dbd6549b923f545d83539 (patch)
treee0318622c5a5576377537783608b60516b46c4cf /src/csharp/Grpc.Core/Internal
parenta14215a67841ea7920260c655c01e4570595a3db (diff)
parentf87a0984ab727e95b068237f3bb0689d9685c8ea (diff)
Merge github.com:grpc/grpc into sometimes-its-good-just-to-check-in-with-each-other
Diffstat (limited to 'src/csharp/Grpc.Core/Internal')
-rw-r--r--src/csharp/Grpc.Core/Internal/Enums.cs15
-rw-r--r--src/csharp/Grpc.Core/Internal/Timespec.cs8
2 files changed, 20 insertions, 3 deletions
diff --git a/src/csharp/Grpc.Core/Internal/Enums.cs b/src/csharp/Grpc.Core/Internal/Enums.cs
index af11b5b9f3..185098160b 100644
--- a/src/csharp/Grpc.Core/Internal/Enums.cs
+++ b/src/csharp/Grpc.Core/Internal/Enums.cs
@@ -90,4 +90,19 @@ namespace Grpc.Core.Internal
/* operation completion */
OpComplete
}
+
+ /// <summary>
+ /// gpr_clock_type from grpc/support/time.h
+ /// </summary>
+ internal enum GPRClockType
+ {
+ /* Monotonic clock */
+ Monotonic,
+
+ /* Realtime clock */
+ Realtime,
+
+ /* Timespan - the distance between two time points */
+ Timespan
+ }
}
diff --git a/src/csharp/Grpc.Core/Internal/Timespec.cs b/src/csharp/Grpc.Core/Internal/Timespec.cs
index 775af27db9..de783f5a4b 100644
--- a/src/csharp/Grpc.Core/Internal/Timespec.cs
+++ b/src/csharp/Grpc.Core/Internal/Timespec.cs
@@ -55,7 +55,8 @@ namespace Grpc.Core.Internal
// NOTE: on linux 64bit sizeof(gpr_timespec) = 16, on windows 32bit sizeof(gpr_timespec) = 8
// so IntPtr seems to have the right size to work on both.
public System.IntPtr tv_sec;
- public System.IntPtr tv_nsec;
+ public int tv_nsec;
+ public GPRClockType clock_type;
/// <summary>
/// Timespec a long time in the future.
@@ -99,12 +100,13 @@ namespace Grpc.Core.Internal
public Timespec Add(TimeSpan timeSpan)
{
- long nanos = tv_nsec.ToInt64() + (timeSpan.Ticks % TimeSpan.TicksPerSecond) * NanosPerTick;
+ long nanos = (long)tv_nsec + (timeSpan.Ticks % TimeSpan.TicksPerSecond) * NanosPerTick;
long overflow_sec = (nanos > NanosPerSecond) ? 1 : 0;
Timespec result;
- result.tv_nsec = new IntPtr(nanos % NanosPerSecond);
+ result.tv_nsec = (int)(nanos % NanosPerSecond);
result.tv_sec = new IntPtr(tv_sec.ToInt64() + (timeSpan.Ticks / TimeSpan.TicksPerSecond) + overflow_sec);
+ result.clock_type = GPRClockType.Realtime;
return result;
}
}