コード例 #1
0
        public void Can_Return()
        {
            using var pool = new OclMemoryPool();

            var platformId = GetPlatforms().First();
            var contextId  = CreateContext(platformId);
            var bufferId   = CreateBuffer <int>(contextId, 1024);

            // Act:
            pool.ReturnBuffer(bufferId);

            ReleaseMemObject(bufferId);
        }
コード例 #2
0
        public void Can_TrimExcess()
        {
            using var pool = new OclMemoryPool();

            var platformId = GetPlatforms().First();
            var contextId  = CreateContext(platformId);
            var bufferId   = CreateBuffer <int>(contextId, 1024);

            pool.ReturnBuffer(bufferId);

            // Act:
            pool.TrimExcess(TimeSpan.Zero);
            var rentedId = pool.RentBuffer <int>(contextId, 1024);

            rentedId.Should().NotBe(bufferId);

            ReleaseMemObject(bufferId);
        }
コード例 #3
0
 public void Return_and_Rent()
 {
     _poolReturn.ReturnBuffer(_bufferId);
     _poolReturn.RentBuffer <int>(_contextId, 1024);
 }