public ConnectionPooling(IConnectionFactory factory, PoolingSettings settings) { this.factory = factory; this.settings = settings; this.connections = new ChannelPooling[Math.Max(1, settings.MinConnections)]; for (int i = 0; i < connections.Length; i++) { connections[i] = new ChannelPooling(factory.CreateConnection(), settings); } totalCount = connections.Length; }
public bool TryCreate(out ChannelPooling pooling) { if (totalCount < settings.MaxConnections) { lock (_addLockObj) { if (totalCount < settings.MaxConnections) { ChannelPooling[] newPooling = new ChannelPooling[this.connections.Length + 1]; this.connections.CopyTo(newPooling, 0); var connection = factory.CreateConnection(); pooling = new ChannelPooling(connection, settings); newPooling[this.connections.Length] = pooling; this.connections = newPooling; totalCount++; return(true); } } } pooling = null; return(false); }
public ChannelWrapper(ChannelPooling pooling, IModel inner) { this.inner = inner; this.pooling = pooling; }