コード例 #1
0
        public void TestUseThreadPoolForRioNative()
        {
            if (!SocketFactory.IsRioSockSupported())
            {
                Assert.Ignore("Omitting due to missing Riosock.dll. It might caused by no VC++ build tool or running on an OS that not supports Windows RIO socket.");
            }

            // Verify default value for no specific executor cores in environment variable.
            RioNative.SetUseThreadPool(true);
            RioNative.EnsureRioLoaded();
            Assert.AreEqual(2, RioNative.GetWorkThreadNumber());
            RioNative.UnloadRio();
            RioNative.SetUseThreadPool(false);

            // Verify the executor cores is less than 2.
            Environment.SetEnvironmentVariable(ConfigurationService.ExecutorCoresEnvName, "1");
            RioNative.SetUseThreadPool(true);
            RioNative.EnsureRioLoaded();
            Assert.AreEqual(2, RioNative.GetWorkThreadNumber());
            RioNative.UnloadRio();
            RioNative.SetUseThreadPool(false);

            // Verify the executor cores is more than 2.
            Environment.SetEnvironmentVariable(ConfigurationService.ExecutorCoresEnvName, "5");
            RioNative.SetUseThreadPool(true);
            RioNative.EnsureRioLoaded();
            Assert.AreEqual(3, RioNative.GetWorkThreadNumber());
            RioNative.UnloadRio();
            RioNative.SetUseThreadPool(false);
        }
コード例 #2
0
        public void TestUseSingleThreadForRioNative()
        {
            if (!SocketFactory.IsRioSockSupported())
            {
                Assert.Ignore("Omitting due to missing Riosock.dll. It might caused by no VC++ build tool or running on an OS that not supports Windows RIO socket.");
            }

            RioNative.SetUseThreadPool(false);
            RioNative.EnsureRioLoaded();
            Assert.AreEqual(1, RioNative.GetWorkThreadNumber());
            RioNative.UnloadRio();
        }