public virtual void Cleanup() { if (Environment != null) { Environment = null; GrpcEnvironment.ReleaseAsync().Wait(); } }
public void CreateSyncAndDestroy() { GrpcEnvironment.AddRef(); var cq = CompletionQueueSafeHandle.CreateSync(); cq.Dispose(); GrpcEnvironment.ReleaseAsync().Wait(); }
public void SubsequentInvocations() { var env1 = GrpcEnvironment.AddRef(); var env2 = GrpcEnvironment.AddRef(); Assert.AreSame(env1, env2); GrpcEnvironment.ReleaseAsync().Wait(); GrpcEnvironment.ReleaseAsync().Wait(); }
public void InitializeAndShutdownGrpcEnvironment() { var env = GrpcEnvironment.AddRef(); Assert.IsTrue(env.CompletionQueues.Count > 0); for (int i = 0; i < env.CompletionQueues.Count; i++) { Assert.IsNotNull(env.CompletionQueues.ElementAt(i)); } GrpcEnvironment.ReleaseAsync().Wait(); }
public void CreateAsyncAndShutdown() { var env = GrpcEnvironment.AddRef(); var cq = CompletionQueueSafeHandle.CreateAsync(new CompletionRegistry(env, () => BatchContextSafeHandle.Create(), () => RequestCallContextSafeHandle.Create())); cq.Shutdown(); var ev = cq.Next(); cq.Dispose(); GrpcEnvironment.ReleaseAsync().Wait(); Assert.AreEqual(CompletionQueueEvent.CompletionType.Shutdown, ev.type); Assert.AreNotEqual(IntPtr.Zero, ev.success); }
public void ShuttingDownEventIsFired() { var cts = new CancellationTokenSource(); var handler = new EventHandler((sender, args) => { cts.Cancel(); }); GrpcEnvironment.ShuttingDown += handler; var env = GrpcEnvironment.AddRef(); GrpcEnvironment.ReleaseAsync().Wait(); GrpcEnvironment.ShuttingDown -= handler; Assert.IsTrue(cts.Token.IsCancellationRequested); }
public void CompletionQueueCreateDestroyBenchmark() { GrpcEnvironment.AddRef(); // completion queue requires gRPC environment being initialized. BenchmarkUtil.RunBenchmark( 10, 10, () => { CompletionQueueSafeHandle cq = CompletionQueueSafeHandle.Create(); cq.Dispose(); }); GrpcEnvironment.ReleaseAsync().Wait(); }
public void CreateAndShutdown() { GrpcEnvironment.AddRef(); var cq = CompletionQueueSafeHandle.Create(); cq.Shutdown(); var ev = cq.Next(); cq.Dispose(); GrpcEnvironment.ReleaseAsync().Wait(); Assert.AreEqual(CompletionQueueEvent.CompletionType.Shutdown, ev.type); Assert.AreNotEqual(IntPtr.Zero, ev.success); Assert.AreEqual(IntPtr.Zero, ev.tag); }
public virtual void Cleanup() { for (int i = 0; i < ThreadCount; i++) { dispatchQueues[i].Add(null); // null action request termination of the worker thread. workers[i].Join(); } if (Environment != null) { Environment = null; GrpcEnvironment.ReleaseAsync().Wait(); } }
public void InitializeAfterShutdown() { Assert.AreEqual(0, GrpcEnvironment.GetRefCount()); var env1 = GrpcEnvironment.AddRef(); GrpcEnvironment.ReleaseAsync().Wait(); var env2 = GrpcEnvironment.AddRef(); GrpcEnvironment.ReleaseAsync().Wait(); Assert.AreNotSame(env1, env2); }
public void Cleanup() { GrpcEnvironment.ReleaseAsync().Wait(); // TODO(jtattermusch): track GC stats }
public void ReleaseWithoutAddRef() { Assert.AreEqual(0, GrpcEnvironment.GetRefCount()); Assert.ThrowsAsync(typeof(InvalidOperationException), async() => await GrpcEnvironment.ReleaseAsync()); }
public void Cleanup() { GrpcEnvironment.ReleaseAsync().Wait(); }