public void Set( IWorkerSocket socket, BufferAllocation bufferAllocation, Action release) { _socket = socket; _release = release; _awaitable.EventArgs .SetBuffer( bufferAllocation.Buffer, bufferAllocation.Offset, bufferAllocation.Size); Closed = false; }
public IWorker Get(IWorkerSocket socket) { Worker worker; if (!_workerPool.TryPop(out worker)) throw new WorkerFactoryException(); var bufferAllocation = _bufferManager.Allocate(); worker.Set( socket, bufferAllocation, () => { _workerPool.Push(worker); _bufferManager.Deallocate(bufferAllocation); }); return worker; }
public void Close() { if (_socket == null) return; _socket.Dispose(); _socket = null; Closed = true; _release(); _logger.Diagnostic(this, () => "Worker Closed"); }