Make RelayPool actor a global actor
This allows us to use the same actor for related classes to help with thread safety. Changelog-None Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
This commit is contained in:
@@ -27,8 +27,15 @@ struct SeenEvent: Hashable {
|
||||
let evid: NoteId
|
||||
}
|
||||
|
||||
@globalActor
|
||||
actor RelayPoolActor {
|
||||
static let shared = RelayPoolActor()
|
||||
private init() {}
|
||||
}
|
||||
|
||||
/// Establishes and manages connections and subscriptions to a list of relays.
|
||||
actor RelayPool {
|
||||
@RelayPoolActor
|
||||
class RelayPool {
|
||||
@MainActor
|
||||
private(set) var relays: [Relay] = []
|
||||
var open: Bool = false
|
||||
@@ -72,7 +79,7 @@ actor RelayPool {
|
||||
seen.removeAll()
|
||||
}
|
||||
|
||||
init(ndb: Ndb?, keypair: Keypair? = nil) {
|
||||
nonisolated init(ndb: Ndb?, keypair: Keypair? = nil) {
|
||||
self.ndb = ndb
|
||||
self.keypair = keypair
|
||||
|
||||
|
||||
Reference in New Issue
Block a user