Move most of RelayPool away from the Main Thread
This is a large refactor that aims to improve performance by offloading RelayPool computations into a separate actor outside the main thread. This should reduce congestion on the main thread and thus improve UI performance. Also, the internal subscription callback mechanism was changed to use AsyncStreams to prevent race conditions newly found in that area of the code. Changelog-Fixed: Added performance improvements to timeline scrolling Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
This commit is contained in:
@@ -64,7 +64,19 @@ enum NdbNoteLender: Sendable {
|
||||
case .owned(let note):
|
||||
return try lendingFunction(UnownedNdbNote(note))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// Borrows the note temporarily (asynchronously)
|
||||
func borrow<T>(_ lendingFunction: (_: borrowing UnownedNdbNote) async throws -> T) async throws -> T {
|
||||
switch self {
|
||||
case .ndbNoteKey(let ndb, let noteKey):
|
||||
guard !ndb.is_closed else { throw LendingError.ndbClosed }
|
||||
guard let ndbNoteTxn = ndb.lookup_note_by_key(noteKey) else { throw LendingError.errorLoadingNote }
|
||||
guard let unownedNote = UnownedNdbNote(ndbNoteTxn) else { throw LendingError.errorLoadingNote }
|
||||
return try await lendingFunction(unownedNote)
|
||||
case .owned(let note):
|
||||
return try await lendingFunction(UnownedNdbNote(note))
|
||||
}
|
||||
}
|
||||
|
||||
/// Gets an owned copy of the note
|
||||
|
||||
Reference in New Issue
Block a user