From e8a72e7bd9a1b7986bc8534c5bc57251ae0dd6be Mon Sep 17 00:00:00 2001 From: John Colvin Date: Wed, 4 Sep 2024 10:38:38 -0400 Subject: [PATCH] refactor: Add 'onDispatcher' param to 'ThreadedBlackboard.subscribe' This will allow us to gradually move subscriptions off of the dispatcher (render) thread. When the render thread is pegged, the ui is laggy and unresponsive. The new param defaults to true, so it won't change anything until we explicitly set it to false in 'subscribe' calls. --- src/client/spark/AW2/Misc/ThreadedBlackboard.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/client/spark/AW2/Misc/ThreadedBlackboard.cs b/src/client/spark/AW2/Misc/ThreadedBlackboard.cs index 328afb3ad..4c0da2f88 100644 --- a/src/client/spark/AW2/Misc/ThreadedBlackboard.cs +++ b/src/client/spark/AW2/Misc/ThreadedBlackboard.cs @@ -49,13 +49,17 @@ namespace mbts.spark { return (T)rv; } - public void subscribe(ITag tag) { + public void subscribe(ITag tag, bool onDispatcher = true) { if (_tag_map.Contains(tag)) { return; } _tag_map.Add(tag); bts.Log.Ui.info($"ThreadedBlackBoard.subscribe tag:{tag} tid:{_tid()}"); - var observable = _bus.subscribe(tag).OnDispatcher().Subscribe( + var source = _bus.subscribe(tag); + if (onDispatcher) { + source = source.OnDispatcher(); + } + var observable = source.Subscribe( data => _on_bus_data(tag, data)); _subs.Add(observable); }