You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
yanggujun edited this page Dec 30, 2019
·
6 revisions
Commons.Pool
Commons.Pool privdes a light weight and thread safe object pool implementation.
Installation
Commons.Pool is delivered as a nuget package. It requires "Commons" package. You can get the package from nuget.org and its dependency Commons
or you can directly install from nuget console by typing following commands:
PM>Install-Package Commons.Pool
Usage Guide
A light weight generic object pool.
// When initializing the IoC container...IocContainer.Register<PoolManager>();//...// Somewhere in the application.varpoolManager=IocContainer.Resolve<IPoolManager>();//...// Create a new pool.varsqlFactory=newDefaultDbConnectionFactory(connectionString);varconnectionPool=poolManager.NewPool<IDbConnection>(c =>{c.InitialSize=0;c.MaxSize=10;c.ByFactory(sqlFactory);});//...varconnection=connectionPool.Acquire();// ...// use the connection.// ...connectionPool.Return(connection);//...// When pool manager is disposed, the pool is disposed too.poolManager.Dispose();