@@ -44,8 +44,7 @@ final class SQLitePackageCollectionsStorage: PackageCollectionsStorage, Closable
44
44
private let ftsLock = Lock ( )
45
45
46
46
private let targetTrie = Trie < CollectionPackage > ( )
47
- private var targetTrieReady = false
48
- private let targetTrieReadyLock = Lock ( )
47
+ private var targetTrieReady = ThreadSafeBox < Bool > ( false )
49
48
50
49
init ( location: SQLite . Location ? = nil , diagnosticsEngine: DiagnosticsEngine ? = nil ) {
51
50
self . location = location ?? . path( localFileSystem. swiftPMCacheDirectory. appending ( components: " package-collection.db " ) )
@@ -433,7 +432,7 @@ final class SQLitePackageCollectionsStorage: PackageCollectionsStorage, Closable
433
432
case . success( let collections) :
434
433
var matches = [ ( collection: Model . CollectionIdentifier, package : PackageIdentity, targetName: String) ] ( )
435
434
// Trie is more performant for target search; use it if available
436
- if self . targetTrieReadyLock . withLock ( { self . targetTrieReady } ) {
435
+ if self . targetTrieReady . get ( ) ?? false {
437
436
do {
438
437
switch type {
439
438
case . exactMatch:
@@ -657,10 +656,10 @@ final class SQLitePackageCollectionsStorage: PackageCollectionsStorage, Closable
657
656
}
658
657
}
659
658
}
660
- self . targetTrieReadyLock . withLock { self . targetTrieReady = true }
659
+ self . targetTrieReady. put ( true )
661
660
callback ( . success( ( ) ) )
662
661
} catch {
663
- self . targetTrieReadyLock . withLock { self . targetTrieReady = false }
662
+ self . targetTrieReady. put ( false )
664
663
callback ( . failure( error) )
665
664
}
666
665
}
0 commit comments