public AsyncCluster(AsyncClientPolicy policy, Host[] hosts) : base(policy, hosts) { maxCommands = policy.asyncMaxCommands; block = policy.asyncMaxCommandAction == MaxCommandAction.BLOCK; argsQueue = new BlockingCollection<SocketAsyncEventArgs>(maxCommands); for (int i = 0; i < maxCommands; i++) { SocketAsyncEventArgs eventArgs = new SocketAsyncEventArgs(); eventArgs.Completed += AsyncCommand.SocketListener; argsQueue.Add(eventArgs); } bufferPool = new BufferPool(); InitTendThread(policy.failIfNotConnected); }
public byte[] GetNextBuffer(int size) { lock (bufferPool) { if (size > bufferPool.bufferSize) { bufferPool = new BufferPool(maxCommands, size); } return bufferPool.GetNextBuffer(); } }
public void GetNextBuffer(int size, BufferSegment segment) { lock (this) { if (size > bufferPool.bufferSize) { bufferPool = new BufferPool(maxCommands, size); } bufferPool.GetNextBuffer(segment); } }