Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
0
 public ChannelWrapper(ChannelPooling pooling, IModel inner)
 {
     this.inner   = inner;
     this.pooling = pooling;
 }