diff options
| author | Bond_009 <bond.009@outlook.com> | 2023-04-14 13:43:56 +0200 |
|---|---|---|
| committer | Bond_009 <bond.009@outlook.com> | 2023-04-21 14:04:37 +0200 |
| commit | 858dadcdd1caadb5fa8cc13a02eb227098f39c3c (patch) | |
| tree | 07a89401de306953c6899008ea59ccea090c132b /Emby.Server.Implementations/Data/ManagedConnection.cs | |
| parent | 20cf27f637af745827348b4853d1e91bdf29eb38 (diff) | |
POC sql connection pool
Diffstat (limited to 'Emby.Server.Implementations/Data/ManagedConnection.cs')
| -rw-r--r-- | Emby.Server.Implementations/Data/ManagedConnection.cs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/Emby.Server.Implementations/Data/ManagedConnection.cs b/Emby.Server.Implementations/Data/ManagedConnection.cs index 11e33278d..e84ed8f91 100644 --- a/Emby.Server.Implementations/Data/ManagedConnection.cs +++ b/Emby.Server.Implementations/Data/ManagedConnection.cs @@ -2,23 +2,22 @@ using System; using System.Collections.Generic; -using System.Threading; using SQLitePCL.pretty; namespace Emby.Server.Implementations.Data { public sealed class ManagedConnection : IDisposable { - private readonly SemaphoreSlim _writeLock; + private readonly ConnectionPool _pool; - private SQLiteDatabaseConnection? _db; + private SQLiteDatabaseConnection _db; private bool _disposed = false; - public ManagedConnection(SQLiteDatabaseConnection db, SemaphoreSlim writeLock) + public ManagedConnection(SQLiteDatabaseConnection db, ConnectionPool pool) { _db = db; - _writeLock = writeLock; + _pool = pool; } public IStatement PrepareStatement(string sql) @@ -73,9 +72,9 @@ namespace Emby.Server.Implementations.Data return; } - _writeLock.Release(); + _pool.Return(_db); - _db = null; // Don't dispose it + _db = null!; // Don't dispose it _disposed = true; } } |
