• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# BufferPool类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中BufferPool的典型用法代码示例。如果您正苦于以下问题:C# BufferPool类的具体用法?C# BufferPool怎么用?C# BufferPool使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BufferPool类属于命名空间,在下文中一共展示了BufferPool类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: a_write_will_automatically_grow_the_buffer_pool

 public void a_write_will_automatically_grow_the_buffer_pool()
 {
     BufferPool pool = new BufferPool(1, BufferManager);
     int initialCapacity = pool.Capacity;
     pool[initialCapacity + 14] = 5;
     Assert.AreEqual(initialCapacity * 2, pool.Capacity);
 }
开发者ID:danieldeb,项目名称:EventStore,代码行数:7,代码来源:BufferPoolTests.cs


示例2: length_is_updated_when_index_higher_than_count_set

 public void length_is_updated_when_index_higher_than_count_set()
 {
     BufferPool pool = new BufferPool(1, BufferManager);
     Assert.AreEqual(0, pool.Length);
     pool[3] = 5;
     Assert.AreEqual(4, pool.Length);
 }
开发者ID:danieldeb,项目名称:EventStore,代码行数:7,代码来源:BufferPoolTests.cs


示例3: SocketServer

 static SocketServer()
 {
     var max = CurrencyStoreSection.Instance.Server.Buffer.MaxLength;
     var size = CurrencyStoreSection.Instance.Server.Buffer.Size;
     socketArgsPool = new SocketArgsPool(max);
     bufferManager = new BufferPool(max * size, size);
     allowAllowAnonymous = CurrencyStoreSection.Instance.Authorization.AllowAnonymous;
 }
开发者ID:kainhong,项目名称:CurrencyStore,代码行数:8,代码来源:SocketServer.cs


示例4: ReleaseBufferTest

 public void ReleaseBufferTest()
 {
     string strBufferName = string.Empty; // TODO: 初始化为适当的值
     long iInitialCapacity = 0; // TODO: 初始化为适当的值
     long iBufferSize = 0; // TODO: 初始化为适当的值
     BufferPool target = new BufferPool( strBufferName, iInitialCapacity, iBufferSize ); // TODO: 初始化为适当的值
     byte[] byteBuffer = null; // TODO: 初始化为适当的值
     target.ReleaseBuffer( byteBuffer );
     Assert.Inconclusive( "无法验证不返回值的方法。" );
 }
开发者ID:andyhebear,项目名称:HappyQ-WowServer,代码行数:10,代码来源:BufferPoolTest.cs


示例5: StartSound

		public void StartSound()
		{
			BufferSizeSamples = Sound.MillisecondsToSamples(Global.Config.SoundBufferSizeMs);
			MaxSamplesDeficit = BufferSizeSamples;

			_sourceID = AL.GenSource();

			_bufferPool = new BufferPool();
			_currentSamplesQueued = 0;
		}
开发者ID:henke37,项目名称:BizHawk,代码行数:10,代码来源:OpenALSoundOutput.cs


示例6: BufferPool

 public void BufferPool()
 {
     BufferPool bp = new BufferPool(10000);
     int ct = 1000;
     for (int i = 0; i < ct; i++) {
         byte[] b = bp.GetBuffer();
         Assert.AreEqual(10000, b.Length);
         bp.ReturnBuffer(b);
     }
     Console.WriteLine("{0} allocations for {1} uses of buffer pool.", bp.NumAllocations, ct);
 }
开发者ID:jburman,项目名称:razordb,代码行数:11,代码来源:PipelineTests.cs


示例7: NetSocket

        internal NetSocket(INetAddress address, BufferPool bufferPool, SocketEventArgPool socketPool, Socket baseSocket)
        {
            this.BufferPool = bufferPool;
            this.SocketPool = socketPool;
            this.BaseSocket = baseSocket;
            this.BaseSocket.NoDelay = true;

            this.IsClient = true;
            this.OnAccepted = delegate { };
            this.OnReceived = delegate { };
            this.OnSent = delegate { };
            this.OnFault = delegate { };
        }
开发者ID:Q-Smith,项目名称:MS.NET-MiniNet,代码行数:13,代码来源:NetSocket.cs


示例8: ThreeThousandGetBuffers

        public void ThreeThousandGetBuffers()
        {
            BufferPool pool = new BufferPool(10 * 1024 * 1024, 1, 1);

                //PLAN:
                //Just like HundredGetBuffers but with 3000 threads

                List<IBuffer> bufferList = new List<IBuffer>();

                int threadNumber = 3000;
                int sizeOdd = 524288;
                int sizeEven = 524288;

                AquireBuffersConcurrently(pool, bufferList, threadNumber, sizeOdd, sizeEven);
                AssertIsContiguous(bufferList);
                Assert.IsTrue(pool.SlabCount == 150 || pool.SlabCount == 151, "SlabCount is " + pool.SlabCount + ". Was expecting 150 or 151");
        }
开发者ID:tenor,项目名称:p2pStateServer,代码行数:17,代码来源:concurrencyTest.cs


示例9: AquireBuffersConcurrently

        private static void AquireBuffersConcurrently(BufferPool pool, List<IBuffer> bufferList, int threadNumber, int sizeOdd, int sizeEven)
        {
            object bufferList_sync = new object();
            ManualResetEvent mre = new ManualResetEvent(false);

            for (int i = 0; i < threadNumber; i++)
            {
                Thread thread = new Thread(delegate(object number)
                {
                    var size = ((int)number % 2 == 1 ? sizeOdd : sizeEven);

                    //wait for signal
                    mre.WaitOne();

                    //Aquire buffer
                    IBuffer buff = pool.GetBuffer(size);

                    //Add to Queue
                    lock (bufferList_sync)
                    {
                        bufferList.Add(buff);
                    }
                });

                thread.IsBackground = true;
                thread.Start(i);
            }

            Thread.Sleep(500); //ensure all threads are waiting for signal

            mre.Set(); //signal event

            //Wait till all threads are done
            while (true)
            {
                lock (bufferList)
                {
                    if (bufferList.Count == threadNumber) break;
                    Thread.Sleep(500);
                }
            }
        }
开发者ID:tenor,项目名称:p2pStateServer,代码行数:42,代码来源:concurrencyTest.cs


示例10: StartSound

		public void StartSound()
		{
			BufferSizeSamples = Sound.MillisecondsToSamples(Global.Config.SoundBufferSizeMs);
			MaxSamplesDeficit = BufferSizeSamples;

			var format = new WaveFormat
				{
					SamplesPerSecond = Sound.SampleRate,
					BitsPerSample = Sound.BytesPerSample * 8,
					Channels = Sound.ChannelCount,
					FormatTag = WaveFormatTag.Pcm,
					BlockAlignment = Sound.BlockAlign,
					AverageBytesPerSecond = Sound.SampleRate * Sound.BlockAlign
				};

			_sourceVoice = new SourceVoice(_device, format);

			_bufferPool = new BufferPool();
			_runningSamplesQueued = 0;

			_sourceVoice.Start();
		}
开发者ID:henke37,项目名称:BizHawk,代码行数:22,代码来源:XAudio2SoundOutput.cs


示例11: HundredGetBuffers

        public void HundredGetBuffers()
        {
            BufferPool pool = new BufferPool(10 * 1024 * 1024, 1, 1);

                //PLAN:
                //Create 100 threads. Odd numbered threads will request buffer sizes of 314567 bytes
                //whereas even numbered threads will request buffer sizes of 314574 bytes
                //for a total allocation of 31457100 bytes.
                //If everything goes well there will be no overlap in allocated buffers
                //and there'll be no free space greater than 314574 (the lower number) on total slabs - 1
                //and slabs should be 4

                List<IBuffer> bufferList = new List<IBuffer>();

                int threadNumber = 100;
                int sizeOdd = 314567;
                int sizeEven = 314574;

                AquireBuffersConcurrently(pool, bufferList, threadNumber, sizeOdd, sizeEven);
                AssertIsContiguous(bufferList);
                Assert.IsTrue(pool.SlabCount == 3 || pool.SlabCount == 4, "SlabCount is " + pool.SlabCount + ". Was expecting 3 or 4");
        }
开发者ID:tenor,项目名称:p2pStateServer,代码行数:22,代码来源:concurrencyTest.cs


示例12: length_is_set_when_setting_length

 public void length_is_set_when_setting_length()
 {
     BufferPool pool = new BufferPool(1, BufferManager);
     pool.SetLength(5000, false);
     Assert.AreEqual(5000, pool.Length);
 }
开发者ID:danieldeb,项目名称:EventStore,代码行数:6,代码来源:BufferPoolTests.cs


示例13: the_byte_array_should_be_the_same_length_as_the_pool_with_data

 public void the_byte_array_should_be_the_same_length_as_the_pool_with_data()
 {
     BufferPool pool = new BufferPool(5, BufferManager);
     for (int i = 0; i < 500; i++)
     {
         pool[i] = 12;
     }
     Assert.AreEqual(500, pool.ToByteArray().Length);
 }
开发者ID:danieldeb,项目名称:EventStore,代码行数:9,代码来源:BufferPoolTests.cs


示例14: data_is_written_to_the_internal_buffer

 public void data_is_written_to_the_internal_buffer()
 {
     BufferPool pool = new BufferPool(1, BufferManager);
     byte[] data = { 1, 2, 3, 4, 5 };
     pool.Append(data);
     for (byte i = 0; i < 5; i++)
     {
         Assert.AreEqual(i + 1, pool[i]);
     }
 }
开发者ID:danieldeb,项目名称:EventStore,代码行数:10,代码来源:BufferPoolTests.cs


示例15: a_write_past_end_will_check_out_a_buffer_from_the_buffer_pool

 public void a_write_past_end_will_check_out_a_buffer_from_the_buffer_pool()
 {
     BufferPool pool = new BufferPool(1, BufferManager);
     int initial = BufferManager.AvailableBuffers;
     pool[pool.Capacity + 14] = 5;
     Assert.AreEqual(initial - 1, BufferManager.AvailableBuffers);
 }
开发者ID:danieldeb,项目名称:EventStore,代码行数:7,代码来源:BufferPoolTests.cs


示例16: data_that_has_been_set_can_read

 public void data_that_has_been_set_can_read()
 {
     BufferPool pool = new BufferPool(1, BufferManager);
     pool[3] = 5;
     Assert.AreEqual(5, pool[3]);
 }
开发者ID:danieldeb,项目名称:EventStore,代码行数:6,代码来源:BufferPoolTests.cs


示例17: pool_can_expand_capacity

 public void pool_can_expand_capacity()
 {
     BufferPool pool = new BufferPool(1, BufferManager);
     int initialCapacity = pool.Capacity;
     byte[] data = new byte[initialCapacity + 25];
     pool.Append(data);
     Assert.AreEqual(initialCapacity * 2, pool.Capacity);
 }
开发者ID:danieldeb,项目名称:EventStore,代码行数:8,代码来源:BufferPoolTests.cs


示例18: Setup

 public override void Setup()
 {
     base.Setup();
     m_DisposedPool = new BufferPool(10, BufferManager);
     m_DisposedPool.Dispose();
 }
开发者ID:danieldeb,项目名称:EventStore,代码行数:6,代码来源:BufferPoolTests.cs


示例19: an_index_under_zero_throws_an_argument_exception

 public void an_index_under_zero_throws_an_argument_exception()
 {
     BufferPool pool = new BufferPool(12, BufferManager);
     Assert.Throws<ArgumentException>(() => pool[-1] = 4);
 }
开发者ID:danieldeb,项目名称:EventStore,代码行数:5,代码来源:BufferPoolTests.cs


示例20: can_write_given_a_self_offset

 public void can_write_given_a_self_offset()
 {
     BufferPool pool = new BufferPool(1, BufferManager);
     byte[] data = { 1, 2, 3, 4, 5 };
     pool.Write(4, data, 0, 5); //start at position 4
     for (byte i = 4; i < 9; i++)
     {
         Assert.AreEqual(i - 3, pool[i]);
     }
 }
开发者ID:danieldeb,项目名称:EventStore,代码行数:10,代码来源:BufferPoolTests.cs



注:本文中的BufferPool类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# BufferUsage类代码示例发布时间:2022-05-24
下一篇:
C# BufferManager类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap