Back to a single connection

This commit is contained in:
Bond-009
2019-03-11 22:33:27 +01:00
committed by Bond_009
parent 30842656a7
commit 27c29bbb4c
10 changed files with 30 additions and 88 deletions

View File

@@ -1,5 +1,4 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Threading;
using SQLitePCL.pretty;
@@ -9,8 +8,7 @@ namespace Emby.Server.Implementations.Data
public class ManagedConnection : IDisposable
{
private SQLiteDatabaseConnection _db;
private SemaphoreSlim _writeLock;
private BlockingCollection<SQLiteDatabaseConnection> _readConPool;
private readonly SemaphoreSlim _writeLock;
private bool _disposed = false;
public ManagedConnection(SQLiteDatabaseConnection db, SemaphoreSlim writeLock)
@@ -19,12 +17,6 @@ namespace Emby.Server.Implementations.Data
_writeLock = writeLock;
}
public ManagedConnection(SQLiteDatabaseConnection db, BlockingCollection<SQLiteDatabaseConnection> queue)
{
_db = db;
_readConPool = queue;
}
public IStatement PrepareStatement(string sql)
{
return _db.PrepareStatement(sql);
@@ -77,8 +69,7 @@ namespace Emby.Server.Implementations.Data
return;
}
_writeLock?.Release();
_readConPool?.Add(_db);
_writeLock.Release();
_db = null; // Don't dispose it
_disposed = true;