Exemple #1
0
 public override void Run()
 {
     Runner = Thread.CurrentThread;
     try
     {
         Pool.acquire();
         OnAcquire.Signal();
         try
         {
             Latch.acquire();
         }
         catch (InterruptedException e)
         {
             throw new Exception(e);
         }
         if (ReleaseConflict.get())
         {
             Pool.release();
             Released.Signal();
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e.ToString());
         Console.Write(e.StackTrace);
     }
 }
Exemple #2
0
 private void Dispose(ChannelContext channelContext)
 {
     channelContext.Channel().close().awaitUninterruptibly();
     if (_channelPool != null)
     {
         _channelPool.release();
     }
 }
Exemple #3
0
        public override void Start()
        {
            _bootstrap = new ClientBootstrap(new NioClientSocketChannelFactory(newCachedThreadPool(daemon(this.GetType().Name + "-boss@" + _destination)), newCachedThreadPool(daemon(this.GetType().Name + "-worker@" + _destination))));
            _bootstrap.PipelineFactory = this;

            _channelPool = new ResourcePoolAnonymousInnerClass(this, _maxUnusedChannels);

            /*
             * This is here to couple the channel releasing to Response.close() itself and not
             * to TransactionStream.close() as it is implemented here. The reason is that a Response
             * that is returned without a TransactionStream will still hold the channel and should
             * release it eventually. Also, logically, closing the channel is not dependent on the
             * TransactionStream.
             */
            _resourcePoolReleaser = () =>
            {
                if (_channelPool != null)
                {
                    _channelPool.release();
                }
            };
        }