public Entry(SQLiteConnectionString connectionString) { ConnectionString = connectionString; Connection = new SQLiteConnectionWithLock(ConnectionString); // If the database is FullMutex, then we don't need to bother locking if (ConnectionString.OpenFlags.HasFlag(SQLiteOpenFlags.FullMutex)) { Connection.SkipLock = true; } }
public void CloseConnection(SQLiteConnectionString connectionString) { var key = connectionString.UniqueKey; Entry entry; lock (_entriesLock) { if (_entries.TryGetValue(key, out entry)) { _entries.Remove(key); } } entry?.Close(); }
public SQLiteConnectionWithLock GetConnectionAndTransactionLock(SQLiteConnectionString connectionString, out object transactionLock) { var key = connectionString.UniqueKey; Entry entry; lock (_entriesLock) { if (!_entries.TryGetValue(key, out entry)) { // The opens the database while we're locked // This is to ensure another thread doesn't get an unopened database entry = new Entry(connectionString); _entries[key] = entry; } transactionLock = entry.TransactionLock; return(entry.Connection); } }
/// <summary> /// Constructs a new SQLiteAsyncConnection and opens a pooled SQLite database /// using the given connection string. /// </summary> /// <param name="connectionString"> /// Details on how to find and open the database. /// </param> public SQLiteAsyncConnection(SQLiteConnectionString connectionString) { _connectionString = connectionString; }
public SQLiteConnectionWithLock GetConnection(SQLiteConnectionString connectionString) { return(GetConnectionAndTransactionLock(connectionString, out var _)); }
/// <summary> /// Initializes a new instance of the <see cref="T:Kit.Sql.Sqlite.SQLiteConnectionWithLock"/> class. /// </summary> /// <param name="connectionString">Connection string containing the DatabasePath.</param> public SQLiteConnectionWithLock(SQLiteConnectionString connectionString) : base(connectionString) { }