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:
@@ -33,7 +33,9 @@ struct NotifyHandler<T> { }
|
||||
|
||||
func notify<T: Notify>(_ notify: Notifications<T>) {
|
||||
let notify = notify.notify
|
||||
NotificationCenter.default.post(name: T.name, object: notify.payload)
|
||||
DispatchQueue.main.async {
|
||||
NotificationCenter.default.post(name: T.name, object: notify.payload)
|
||||
}
|
||||
}
|
||||
|
||||
func handle_notify<T: Notify>(_ handler: NotifyHandler<T>) -> AnyPublisher<T.Payload, Never> {
|
||||
|
||||
@@ -37,6 +37,6 @@ extension Notifications {
|
||||
/// The requests from this function will be received and handled at the top level app view (`ContentView`), which contains a `.damus_full_screen_cover`.
|
||||
///
|
||||
func present(full_screen_item: FullScreenItem) {
|
||||
notify(.present_full_screen_item(full_screen_item))
|
||||
Task { await notify(.present_full_screen_item(full_screen_item)) }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user