mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 10:42:52 +08:00
移入 SafeObjectPool 源码
This commit is contained in:
parent
2544db5c4b
commit
2f32e0e71c
@ -2982,6 +2982,11 @@
|
|||||||
获取超时后,是否抛出异常
|
获取超时后,是否抛出异常
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="P:FreeSql.Internal.ObjectPool.IPolicy`1.IsAutoDisposeWithSystem">
|
||||||
|
<summary>
|
||||||
|
监听 AppDomain.CurrentDomain.ProcessExit/Console.CancelKeyPress 事件自动释放
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
<member name="P:FreeSql.Internal.ObjectPool.IPolicy`1.CheckAvailableInterval">
|
<member name="P:FreeSql.Internal.ObjectPool.IPolicy`1.CheckAvailableInterval">
|
||||||
<summary>
|
<summary>
|
||||||
后台定时检查可用性间隔秒数
|
后台定时检查可用性间隔秒数
|
||||||
|
@ -105,9 +105,10 @@ namespace FreeSql.Internal.CommonProvider
|
|||||||
public string Name { get; set; } = typeof(DbConnectionPoolPolicy).GetType().FullName;
|
public string Name { get; set; } = typeof(DbConnectionPoolPolicy).GetType().FullName;
|
||||||
public int PoolSize { get; set; } = 1000;
|
public int PoolSize { get; set; } = 1000;
|
||||||
public TimeSpan SyncGetTimeout { get; set; } = TimeSpan.FromSeconds(10);
|
public TimeSpan SyncGetTimeout { get; set; } = TimeSpan.FromSeconds(10);
|
||||||
public TimeSpan IdleTimeout { get; set; } = TimeSpan.FromSeconds(50);
|
public TimeSpan IdleTimeout { get; set; } = TimeSpan.FromSeconds(20);
|
||||||
public int AsyncGetCapacity { get; set; } = 10000;
|
public int AsyncGetCapacity { get; set; } = 10000;
|
||||||
public bool IsThrowGetTimeoutException { get; set; } = true;
|
public bool IsThrowGetTimeoutException { get; set; } = true;
|
||||||
|
public bool IsAutoDisposeWithSystem { get; set; } = true;
|
||||||
public int CheckAvailableInterval { get; set; } = 5;
|
public int CheckAvailableInterval { get; set; } = 5;
|
||||||
|
|
||||||
public DbConnection OnCreate()
|
public DbConnection OnCreate()
|
||||||
|
@ -15,6 +15,7 @@ namespace FreeSql.Internal.ObjectPool
|
|||||||
public TimeSpan IdleTimeout { get; set; } = TimeSpan.FromSeconds(50);
|
public TimeSpan IdleTimeout { get; set; } = TimeSpan.FromSeconds(50);
|
||||||
public int AsyncGetCapacity { get; set; } = 10000;
|
public int AsyncGetCapacity { get; set; } = 10000;
|
||||||
public bool IsThrowGetTimeoutException { get; set; } = true;
|
public bool IsThrowGetTimeoutException { get; set; } = true;
|
||||||
|
public bool IsAutoDisposeWithSystem { get; set; } = true;
|
||||||
public int CheckAvailableInterval { get; set; } = 5;
|
public int CheckAvailableInterval { get; set; } = 5;
|
||||||
|
|
||||||
public Func<T> CreateObject;
|
public Func<T> CreateObject;
|
||||||
|
@ -38,6 +38,11 @@ namespace FreeSql.Internal.ObjectPool
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
bool IsThrowGetTimeoutException { get; set; }
|
bool IsThrowGetTimeoutException { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 监听 AppDomain.CurrentDomain.ProcessExit/Console.CancelKeyPress 事件自动释放
|
||||||
|
/// </summary>
|
||||||
|
bool IsAutoDisposeWithSystem { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 后台定时检查可用性间隔秒数
|
/// 后台定时检查可用性间隔秒数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -241,14 +241,16 @@ namespace FreeSql.Internal.ObjectPool
|
|||||||
|
|
||||||
AppDomain.CurrentDomain.ProcessExit += (s1, e1) =>
|
AppDomain.CurrentDomain.ProcessExit += (s1, e1) =>
|
||||||
{
|
{
|
||||||
running = false;
|
if (Policy.IsAutoDisposeWithSystem)
|
||||||
|
running = false;
|
||||||
};
|
};
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Console.CancelKeyPress += (s1, e1) =>
|
Console.CancelKeyPress += (s1, e1) =>
|
||||||
{
|
{
|
||||||
if (e1.Cancel) return;
|
if (e1.Cancel) return;
|
||||||
running = false;
|
if (Policy.IsAutoDisposeWithSystem)
|
||||||
|
running = false;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
|
@ -55,6 +55,7 @@ namespace FreeSql.MsAccess
|
|||||||
public TimeSpan IdleTimeout { get; set; } = TimeSpan.Zero;
|
public TimeSpan IdleTimeout { get; set; } = TimeSpan.Zero;
|
||||||
public int AsyncGetCapacity { get; set; } = 10000;
|
public int AsyncGetCapacity { get; set; } = 10000;
|
||||||
public bool IsThrowGetTimeoutException { get; set; } = true;
|
public bool IsThrowGetTimeoutException { get; set; } = true;
|
||||||
|
public bool IsAutoDisposeWithSystem { get; set; } = true;
|
||||||
public int CheckAvailableInterval { get; set; } = 5;
|
public int CheckAvailableInterval { get; set; } = 5;
|
||||||
|
|
||||||
private string _connectionString;
|
private string _connectionString;
|
||||||
|
@ -50,6 +50,7 @@ namespace FreeSql.MySql
|
|||||||
public TimeSpan IdleTimeout { get; set; } = TimeSpan.FromSeconds(20);
|
public TimeSpan IdleTimeout { get; set; } = TimeSpan.FromSeconds(20);
|
||||||
public int AsyncGetCapacity { get; set; } = 10000;
|
public int AsyncGetCapacity { get; set; } = 10000;
|
||||||
public bool IsThrowGetTimeoutException { get; set; } = true;
|
public bool IsThrowGetTimeoutException { get; set; } = true;
|
||||||
|
public bool IsAutoDisposeWithSystem { get; set; } = true;
|
||||||
public int CheckAvailableInterval { get; set; } = 5;
|
public int CheckAvailableInterval { get; set; } = 5;
|
||||||
|
|
||||||
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
||||||
|
@ -72,6 +72,7 @@ namespace FreeSql.Odbc.Dameng
|
|||||||
public TimeSpan IdleTimeout { get; set; } = TimeSpan.FromSeconds(20);
|
public TimeSpan IdleTimeout { get; set; } = TimeSpan.FromSeconds(20);
|
||||||
public int AsyncGetCapacity { get; set; } = 10000;
|
public int AsyncGetCapacity { get; set; } = 10000;
|
||||||
public bool IsThrowGetTimeoutException { get; set; } = true;
|
public bool IsThrowGetTimeoutException { get; set; } = true;
|
||||||
|
public bool IsAutoDisposeWithSystem { get; set; } = true;
|
||||||
public int CheckAvailableInterval { get; set; } = 5;
|
public int CheckAvailableInterval { get; set; } = 5;
|
||||||
|
|
||||||
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
||||||
|
@ -55,6 +55,7 @@ namespace FreeSql.Odbc.Default
|
|||||||
public TimeSpan IdleTimeout { get; set; } = TimeSpan.FromSeconds(20);
|
public TimeSpan IdleTimeout { get; set; } = TimeSpan.FromSeconds(20);
|
||||||
public int AsyncGetCapacity { get; set; } = 10000;
|
public int AsyncGetCapacity { get; set; } = 10000;
|
||||||
public bool IsThrowGetTimeoutException { get; set; } = true;
|
public bool IsThrowGetTimeoutException { get; set; } = true;
|
||||||
|
public bool IsAutoDisposeWithSystem { get; set; } = true;
|
||||||
public int CheckAvailableInterval { get; set; } = 5;
|
public int CheckAvailableInterval { get; set; } = 5;
|
||||||
|
|
||||||
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
||||||
|
@ -50,6 +50,7 @@ namespace FreeSql.Odbc.MySql
|
|||||||
public TimeSpan IdleTimeout { get; set; } = TimeSpan.FromSeconds(20);
|
public TimeSpan IdleTimeout { get; set; } = TimeSpan.FromSeconds(20);
|
||||||
public int AsyncGetCapacity { get; set; } = 10000;
|
public int AsyncGetCapacity { get; set; } = 10000;
|
||||||
public bool IsThrowGetTimeoutException { get; set; } = true;
|
public bool IsThrowGetTimeoutException { get; set; } = true;
|
||||||
|
public bool IsAutoDisposeWithSystem { get; set; } = true;
|
||||||
public int CheckAvailableInterval { get; set; } = 5;
|
public int CheckAvailableInterval { get; set; } = 5;
|
||||||
|
|
||||||
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
||||||
|
@ -72,6 +72,7 @@ namespace FreeSql.Odbc.Oracle
|
|||||||
public TimeSpan IdleTimeout { get; set; } = TimeSpan.FromSeconds(20);
|
public TimeSpan IdleTimeout { get; set; } = TimeSpan.FromSeconds(20);
|
||||||
public int AsyncGetCapacity { get; set; } = 10000;
|
public int AsyncGetCapacity { get; set; } = 10000;
|
||||||
public bool IsThrowGetTimeoutException { get; set; } = true;
|
public bool IsThrowGetTimeoutException { get; set; } = true;
|
||||||
|
public bool IsAutoDisposeWithSystem { get; set; } = true;
|
||||||
public int CheckAvailableInterval { get; set; } = 5;
|
public int CheckAvailableInterval { get; set; } = 5;
|
||||||
|
|
||||||
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
||||||
|
@ -62,6 +62,7 @@ namespace FreeSql.Odbc.PostgreSQL
|
|||||||
public TimeSpan IdleTimeout { get; set; } = TimeSpan.FromSeconds(20);
|
public TimeSpan IdleTimeout { get; set; } = TimeSpan.FromSeconds(20);
|
||||||
public int AsyncGetCapacity { get; set; } = 10000;
|
public int AsyncGetCapacity { get; set; } = 10000;
|
||||||
public bool IsThrowGetTimeoutException { get; set; } = true;
|
public bool IsThrowGetTimeoutException { get; set; } = true;
|
||||||
|
public bool IsAutoDisposeWithSystem { get; set; } = true;
|
||||||
public int CheckAvailableInterval { get; set; } = 5;
|
public int CheckAvailableInterval { get; set; } = 5;
|
||||||
|
|
||||||
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
||||||
|
@ -55,6 +55,7 @@ namespace FreeSql.Odbc.SqlServer
|
|||||||
public TimeSpan IdleTimeout { get; set; } = TimeSpan.FromSeconds(20);
|
public TimeSpan IdleTimeout { get; set; } = TimeSpan.FromSeconds(20);
|
||||||
public int AsyncGetCapacity { get; set; } = 10000;
|
public int AsyncGetCapacity { get; set; } = 10000;
|
||||||
public bool IsThrowGetTimeoutException { get; set; } = true;
|
public bool IsThrowGetTimeoutException { get; set; } = true;
|
||||||
|
public bool IsAutoDisposeWithSystem { get; set; } = true;
|
||||||
public int CheckAvailableInterval { get; set; } = 5;
|
public int CheckAvailableInterval { get; set; } = 5;
|
||||||
|
|
||||||
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
||||||
|
@ -72,6 +72,7 @@ namespace FreeSql.Oracle
|
|||||||
public TimeSpan IdleTimeout { get; set; } = TimeSpan.FromSeconds(20);
|
public TimeSpan IdleTimeout { get; set; } = TimeSpan.FromSeconds(20);
|
||||||
public int AsyncGetCapacity { get; set; } = 10000;
|
public int AsyncGetCapacity { get; set; } = 10000;
|
||||||
public bool IsThrowGetTimeoutException { get; set; } = true;
|
public bool IsThrowGetTimeoutException { get; set; } = true;
|
||||||
|
public bool IsAutoDisposeWithSystem { get; set; } = true;
|
||||||
public int CheckAvailableInterval { get; set; } = 5;
|
public int CheckAvailableInterval { get; set; } = 5;
|
||||||
|
|
||||||
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
||||||
|
@ -62,6 +62,7 @@ namespace FreeSql.PostgreSQL
|
|||||||
public TimeSpan IdleTimeout { get; set; } = TimeSpan.FromSeconds(20);
|
public TimeSpan IdleTimeout { get; set; } = TimeSpan.FromSeconds(20);
|
||||||
public int AsyncGetCapacity { get; set; } = 10000;
|
public int AsyncGetCapacity { get; set; } = 10000;
|
||||||
public bool IsThrowGetTimeoutException { get; set; } = true;
|
public bool IsThrowGetTimeoutException { get; set; } = true;
|
||||||
|
public bool IsAutoDisposeWithSystem { get; set; } = true;
|
||||||
public int CheckAvailableInterval { get; set; } = 5;
|
public int CheckAvailableInterval { get; set; } = 5;
|
||||||
|
|
||||||
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
||||||
|
@ -55,6 +55,7 @@ namespace FreeSql.SqlServer
|
|||||||
public TimeSpan IdleTimeout { get; set; } = TimeSpan.FromSeconds(20);
|
public TimeSpan IdleTimeout { get; set; } = TimeSpan.FromSeconds(20);
|
||||||
public int AsyncGetCapacity { get; set; } = 10000;
|
public int AsyncGetCapacity { get; set; } = 10000;
|
||||||
public bool IsThrowGetTimeoutException { get; set; } = true;
|
public bool IsThrowGetTimeoutException { get; set; } = true;
|
||||||
|
public bool IsAutoDisposeWithSystem { get; set; } = true;
|
||||||
public int CheckAvailableInterval { get; set; } = 5;
|
public int CheckAvailableInterval { get; set; } = 5;
|
||||||
|
|
||||||
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
static ConcurrentDictionary<string, int> dicConnStrIncr = new ConcurrentDictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);
|
||||||
|
@ -54,6 +54,7 @@ namespace FreeSql.Sqlite
|
|||||||
public TimeSpan IdleTimeout { get; set; } = TimeSpan.Zero;
|
public TimeSpan IdleTimeout { get; set; } = TimeSpan.Zero;
|
||||||
public int AsyncGetCapacity { get; set; } = 10000;
|
public int AsyncGetCapacity { get; set; } = 10000;
|
||||||
public bool IsThrowGetTimeoutException { get; set; } = true;
|
public bool IsThrowGetTimeoutException { get; set; } = true;
|
||||||
|
public bool IsAutoDisposeWithSystem { get; set; } = true;
|
||||||
public int CheckAvailableInterval { get; set; } = 5;
|
public int CheckAvailableInterval { get; set; } = 5;
|
||||||
public string[] Attaches = new string[0];
|
public string[] Attaches = new string[0];
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user