public void Add_Nanos() { var t = new Timespec { tv_sec = new IntPtr(12345), tv_nsec = 123456789 }; var result = t.Add(TimeSpan.FromTicks(10)); Assert.AreEqual(result.tv_sec, new IntPtr(12345)); Assert.AreEqual(result.tv_nsec, 123456789 + 1000); }
public void Add_NanosOverflow() { var t = new Timespec { tv_sec = new IntPtr(12345), tv_nsec = 999999999 }; var result = t.Add(TimeSpan.FromTicks(TimeSpan.TicksPerSecond * 10 + 10)); Assert.AreEqual(result.tv_sec, new IntPtr(12356)); Assert.AreEqual(result.tv_nsec, 999); }
public void WatchConnectivityState(ChannelState lastObservedState, Timespec deadline, CompletionQueueSafeHandle cq, CompletionRegistry completionRegistry, BatchCompletionDelegate callback) { var ctx = BatchContextSafeHandle.Create(); completionRegistry.RegisterBatchCompletion(ctx, callback); Native.grpcsharp_channel_watch_connectivity_state(this, lastObservedState, deadline, cq, ctx); }
public void Add() { var t = new Timespec { tv_sec = new IntPtr(12345), tv_nsec = 123456789 }; var result = t.Add(TimeSpan.FromTicks(TimeSpan.TicksPerSecond * 10)); Assert.AreEqual(result.tv_sec, new IntPtr(12355)); Assert.AreEqual(result.tv_nsec, 123456789); }
public ServerRpcNew(Server server, CallSafeHandle call, string method, string host, Timespec deadline, Metadata requestMetadata) { this.server = server; this.call = call; this.method = method; this.host = host; this.deadline = deadline; this.requestMetadata = requestMetadata; }
public CallSafeHandle CreateCall(CallSafeHandle parentCall, ContextPropagationFlags propagationMask, CompletionQueueSafeHandle cq, string method, string host, Timespec deadline, CallCredentialsSafeHandle credentials) { var result = Native.grpcsharp_channel_create_call(this, parentCall, propagationMask, cq, method, host, deadline); if (credentials != null) { result.SetCredentials(credentials); } result.Initialize(cq); return result; }
public CallSafeHandle CreateCall(CompletionRegistry registry, CallSafeHandle parentCall, ContextPropagationFlags propagationMask, CompletionQueueSafeHandle cq, string method, string host, Timespec deadline, CredentialsSafeHandle credentials) { using (Profilers.ForCurrentThread().NewScope("ChannelSafeHandle.CreateCall")) { var result = grpcsharp_channel_create_call(this, parentCall, propagationMask, cq, method, host, deadline); if (credentials != null) { result.SetCredentials(credentials); } result.SetCompletionRegistry(registry); return result; } }
private INativeCall CreateNativeCall(CompletionQueueSafeHandle cq) { using (Profilers.ForCurrentThread().NewScope("AsyncCall.CreateNativeCall")) { if (injectedNativeCall != null) { return(injectedNativeCall); // allows injecting a mock INativeCall in tests. } var parentCall = details.Options.PropagationToken != null ? details.Options.PropagationToken.ParentCall : CallSafeHandle.NullInstance; var credentials = details.Options.Credentials; using (var nativeCredentials = credentials != null ? credentials.ToNativeCredentials() : null) { var result = details.Channel.Handle.CreateCall( parentCall, ContextPropagationToken.DefaultMask, cq, details.Method, details.Host, Timespec.FromDateTime(details.Options.Deadline.Value), nativeCredentials); return(result); } } }
public void ToDateTime_OutOfDateTimeRange() { // DateTime range goes up to year 9999, 20000 years from now should // be out of range. long seconds = 20000L * 365L * 24L * 3600L; var timespec = new Timespec(seconds, 0); Assert.AreNotEqual(Timespec.InfFuture, timespec); Assert.AreEqual(DateTime.MaxValue, timespec.ToDateTime()); Assert.AreEqual(DateTime.MinValue, new Timespec(-seconds, 0).ToDateTime()); }
public static CallSafeHandle Create(ChannelSafeHandle channel, CompletionRegistry registry, CompletionQueueSafeHandle cq, string method, string host, Timespec deadline) { var result = grpcsharp_channel_create_call(channel, cq, method, host, deadline); result.SetCompletionRegistry(registry); return(result); }
public void ToDateTime_Overflow() { // we can only get overflow in ticks arithmetic on 64-bit if (IntPtr.Size == 8) { var timespec = new Timespec(new IntPtr(long.MaxValue - 100), 0); Assert.AreNotEqual(Timespec.InfFuture, timespec); Assert.AreEqual(DateTime.MaxValue, timespec.ToDateTime()); Assert.AreEqual(DateTime.MinValue, new Timespec(new IntPtr(long.MinValue + 100), 0).ToDateTime()); } else { Console.WriteLine("Test cannot be run on this platform, skipping the test."); } }
public void ToDateTime_Overflow() { var timespec = new Timespec(long.MaxValue - 100, 0); Assert.AreNotEqual(Timespec.InfFuture, timespec); Assert.AreEqual(DateTime.MaxValue, timespec.ToDateTime()); Assert.AreEqual(DateTime.MinValue, new Timespec(long.MinValue + 100, 0).ToDateTime()); }
internal static extern Timespec gprsharp_convert_clock_type(Timespec t, ClockType targetClock);
static extern void grpcsharp_channel_watch_connectivity_state(ChannelSafeHandle channel, ChannelState lastObservedState, Timespec deadline, CompletionQueueSafeHandle cq, BatchContextSafeHandle ctx);
CallSafeHandle IPlatformInvocation.grpcsharp_channel_create_call(ChannelSafeHandle channel, CallSafeHandle parentCall, ContextPropagationFlags propagationMask, CompletionQueueSafeHandle cq, string method, string host, Timespec deadline) { return grpcsharp_channel_create_call(channel, parentCall, propagationMask, cq, method, host, deadline); }
public CallSafeHandle CreateCall(CompletionRegistry registry, CallSafeHandle parentCall, ContextPropagationFlags propagationMask, CompletionQueueSafeHandle cq, string method, string host, Timespec deadline, CallCredentialsSafeHandle credentials) { using (Profilers.ForCurrentThread().NewScope("ChannelSafeHandle.CreateCall")) { var result = Native.grpcsharp_channel_create_call(this, parentCall, propagationMask, cq, method, host, deadline); if (credentials != null) { result.SetCredentials(credentials); } result.Initialize(registry, cq); return(result); } }
private void Initialize(CompletionQueueSafeHandle cq) { var parentCall = details.Options.PropagationToken != null ? details.Options.PropagationToken.ParentCall : CallSafeHandle.NullInstance; var call = details.Channel.Handle.CreateCall(details.Channel.Environment.CompletionRegistry, parentCall, ContextPropagationToken.DefaultMask, cq, details.Method, details.Host, Timespec.FromDateTime(details.Options.Deadline.Value)); details.Channel.AddCallReference(this); InitializeInternal(call); RegisterCancellationCallback(); }
void IPlatformInvocation.grpcsharp_channel_watch_connectivity_state(ChannelSafeHandle channel, ChannelState lastObservedState, Timespec deadline, CompletionQueueSafeHandle cq, BatchContextSafeHandle ctx) { grpcsharp_channel_watch_connectivity_state(channel, lastObservedState, deadline, cq, ctx); }
public static CallSafeHandle Create(ChannelSafeHandle channel, CompletionQueueSafeHandle cq, string method, string host, Timespec deadline) { return(grpcsharp_channel_create_call(channel, cq, method, host, deadline)); }
static extern CallSafeHandle grpcsharp_channel_create_call(ChannelSafeHandle channel, CompletionQueueSafeHandle cq, string method, string host, Timespec deadline);
public CallSafeHandle CreateCall(CompletionRegistry registry, CompletionQueueSafeHandle cq, string method, string host, Timespec deadline) { var result = grpcsharp_channel_create_call(this, cq, method, host, deadline); result.SetCompletionRegistry(registry); return result; }
public static CallSafeHandle Create(ChannelSafeHandle channel, CompletionQueueSafeHandle cq, string method, string host, Timespec deadline) { return grpcsharp_channel_create_call(channel, cq, method, host, deadline); }
public void WatchConnectivityState(ChannelState lastObservedState, Timespec deadline, CompletionQueueSafeHandle cq, BatchCompletionDelegate callback, object callbackState) { var ctx = cq.CompletionRegistry.RegisterBatchCompletion(callback, callbackState); Native.grpcsharp_channel_watch_connectivity_state(this, lastObservedState, deadline, cq, ctx); }
public ProfilerEntry(Timespec timespec, Type type, string tag) { this.timespec = timespec; this.type = type; this.tag = tag; }
CallSafeHandle IPlatformInvocation.grpcsharp_channel_create_call(ChannelSafeHandle channel, CallSafeHandle parentCall, ContextPropagationFlags propagationMask, CompletionQueueSafeHandle cq, string method, string host, Timespec deadline) { return(grpcsharp_channel_create_call(channel, parentCall, propagationMask, cq, method, host, deadline)); }
static extern Timespec gprsharp_convert_clock_type(Timespec t, GPRClockType targetClock);
Timespec IPlatformInvocation.gprsharp_convert_clock_type(Timespec t, GPRClockType targetClock) { return(gprsharp_convert_clock_type(t, targetClock)); }
internal static extern CallSafeHandle grpcsharp_channel_create_call(ChannelSafeHandle channel, CallSafeHandle parentCall, ContextPropagationFlags propagationMask, CompletionQueueSafeHandle cq, string method, string host, Timespec deadline);
public void ToDateTime_OutOfDateTimeRange() { // we can only get out of range on 64-bit, on 32 bit the max // timestamp is ~ Jan 19 2038, which is far within range of DateTime // same case for min value. if (IntPtr.Size == 8) { // DateTime range goes up to year 9999, 20000 years from now should // be out of range. long seconds = 20000L * 365L * 24L * 3600L; var timespec = new Timespec(new IntPtr(seconds), 0); Assert.AreNotEqual(Timespec.InfFuture, timespec); Assert.AreEqual(DateTime.MaxValue, timespec.ToDateTime()); Assert.AreEqual(DateTime.MinValue, new Timespec(new IntPtr(-seconds), 0).ToDateTime()); } else { Console.WriteLine("Test cannot be run on this platform, skipping the test"); } }
Timespec IPlatformInvocation.gprsharp_convert_clock_type(Timespec t, GPRClockType targetClock) { return gprsharp_convert_clock_type(t, targetClock); }
public CallSafeHandle CreateCall(CallSafeHandle parentCall, ContextPropagationFlags propagationMask, CompletionQueueSafeHandle cq, string method, string host, Timespec deadline, CallCredentialsSafeHandle credentials) { var result = Native.grpcsharp_channel_create_call(this, parentCall, propagationMask, cq, method, host, deadline); if (credentials != null) { result.SetCredentials(credentials); } result.Initialize(cq); return(result); }
internal static extern void grpcsharp_channel_watch_connectivity_state(ChannelSafeHandle channel, ChannelState lastObservedState, Timespec deadline, CompletionQueueSafeHandle cq, BatchContextSafeHandle ctx);
static extern CallSafeHandle grpcsharp_channel_create_call(ChannelSafeHandle channel, CallSafeHandle parentCall, ContextPropagationFlags propagationMask, CompletionQueueSafeHandle cq, string method, string host, Timespec deadline);
public CallSafeHandle CreateCall(CompletionRegistry registry, CallSafeHandle parentCall, ContextPropagationFlags propagationMask, CompletionQueueSafeHandle cq, string method, string host, Timespec deadline) { var result = grpcsharp_channel_create_call(this, parentCall, propagationMask, cq, method, host, deadline); result.SetCompletionRegistry(registry); return(result); }
public CallSafeHandle CreateCall(CompletionRegistry registry, CallSafeHandle parentCall, ContextPropagationFlags propagationMask, CompletionQueueSafeHandle cq, string method, string host, Timespec deadline) { var result = grpcsharp_channel_create_call(this, parentCall, propagationMask, cq, method, host, deadline); result.SetCompletionRegistry(registry); return result; }
private INativeCall CreateNativeCall(CompletionQueueSafeHandle cq) { if (injectedNativeCall != null) { return(injectedNativeCall); // allows injecting a mock INativeCall in tests. } var parentCall = details.Options.PropagationToken != null ? details.Options.PropagationToken.ParentCall : CallSafeHandle.NullInstance; var credentials = details.Options.Credentials; using (var nativeCredentials = credentials != null ? credentials.ToNativeCredentials() : null) { return(details.Channel.Handle.CreateCall(environment.CompletionRegistry, parentCall, ContextPropagationToken.DefaultMask, cq, details.Method, details.Host, Timespec.FromDateTime(details.Options.Deadline.Value), nativeCredentials)); } }