コード例 #1
0
 public virtual void Cleanup()
 {
     if (Environment != null)
     {
         Environment = null;
         GrpcEnvironment.ReleaseAsync().Wait();
     }
 }
コード例 #2
0
        public void CreateSyncAndDestroy()
        {
            GrpcEnvironment.AddRef();
            var cq = CompletionQueueSafeHandle.CreateSync();

            cq.Dispose();
            GrpcEnvironment.ReleaseAsync().Wait();
        }
コード例 #3
0
ファイル: GrpcEnvironmentTest.cs プロジェクト: zzzhr1990/grpc
        public void SubsequentInvocations()
        {
            var env1 = GrpcEnvironment.AddRef();
            var env2 = GrpcEnvironment.AddRef();

            Assert.AreSame(env1, env2);
            GrpcEnvironment.ReleaseAsync().Wait();
            GrpcEnvironment.ReleaseAsync().Wait();
        }
コード例 #4
0
ファイル: GrpcEnvironmentTest.cs プロジェクト: zzzhr1990/grpc
        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();
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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();
        }
コード例 #8
0
        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);
        }
コード例 #9
0
        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();
            }
        }
コード例 #10
0
ファイル: GrpcEnvironmentTest.cs プロジェクト: zzzhr1990/grpc
        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);
        }
コード例 #11
0
 public void Cleanup()
 {
     GrpcEnvironment.ReleaseAsync().Wait();
     // TODO(jtattermusch): track GC stats
 }
コード例 #12
0
ファイル: GrpcEnvironmentTest.cs プロジェクト: zzzhr1990/grpc
 public void ReleaseWithoutAddRef()
 {
     Assert.AreEqual(0, GrpcEnvironment.GetRefCount());
     Assert.ThrowsAsync(typeof(InvalidOperationException), async() => await GrpcEnvironment.ReleaseAsync());
 }
コード例 #13
0
 public void Cleanup()
 {
     GrpcEnvironment.ReleaseAsync().Wait();
 }