From 13152bf09dcadf8807e1240be7ca84662d2ed397 Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Fri, 21 Apr 2023 14:05:27 +0200 Subject: Change number of read connections based on # of threads and add comments --- Emby.Server.Implementations/Data/ConnectionPool.cs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'Emby.Server.Implementations/Data/ConnectionPool.cs') diff --git a/Emby.Server.Implementations/Data/ConnectionPool.cs b/Emby.Server.Implementations/Data/ConnectionPool.cs index 091a1b74f..6d28a5e43 100644 --- a/Emby.Server.Implementations/Data/ConnectionPool.cs +++ b/Emby.Server.Implementations/Data/ConnectionPool.cs @@ -1,16 +1,22 @@ -#pragma warning disable CS1591 - using System; using System.Collections.Concurrent; using SQLitePCL.pretty; namespace Emby.Server.Implementations.Data; +/// +/// A pool of SQLite Database connections. +/// public sealed class ConnectionPool : IDisposable { private readonly BlockingCollection _connections = new(); private bool _disposed; + /// + /// Initializes a new instance of the class. + /// + /// The number of database connection to create. + /// Factory function to create the database connections. public ConnectionPool(int count, Func factory) { for (int i = 0; i < count; i++) @@ -19,6 +25,10 @@ public sealed class ConnectionPool : IDisposable } } + /// + /// Gets a database connection from the pool if one is available, otherwise blocks. + /// + /// A database connection. public ManagedConnection GetConnection() { if (_disposed) @@ -34,6 +44,10 @@ public sealed class ConnectionPool : IDisposable } } + /// + /// Return a database connection to the pool. + /// + /// The database connection to return. public void Return(SQLiteDatabaseConnection connection) { if (_disposed) @@ -45,6 +59,7 @@ public sealed class ConnectionPool : IDisposable _connections.Add(connection); } + /// public void Dispose() { if (_disposed) -- cgit v1.2.3