@@ -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 " ) )
@@ -421,7 +420,7 @@ final class SQLitePackageCollectionsStorage: PackageCollectionsStorage, Closable
421
420
case . success( let collections) :
422
421
var matches = [ ( collection: Model . CollectionIdentifier, package : PackageIdentity, targetName: String) ] ( )
423
422
// Trie is more performant for target search; use it if available
424
- if self . targetTrieReadyLock . withLock ( { self . targetTrieReady } ) {
423
+ if self . targetTrieReady . get ( ) ?? false {
425
424
do {
426
425
switch type {
427
426
case . exactMatch:
@@ -643,10 +642,10 @@ final class SQLitePackageCollectionsStorage: PackageCollectionsStorage, Closable
643
642
}
644
643
}
645
644
}
646
- self . targetTrieReadyLock . withLock { self . targetTrieReady = true }
645
+ self . targetTrieReady. put ( true )
647
646
callback ( . success( ( ) ) )
648
647
} catch {
649
- self . targetTrieReadyLock . withLock { self . targetTrieReady = false }
648
+ self . targetTrieReady. put ( false )
650
649
callback ( . failure( error) )
651
650
}
652
651
}
0 commit comments