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.
This commit is contained in:
1 parent
e99e2d817a
commit
e8a72e7bd9
1 file changed
+6
-2
@@ -49,13 +49,17 @@ namespace mbts.spark {
|
||||
return (T)rv;
|
||||
}
|
||||
|
||||
public void subscribe<T>(ITag<T> tag) {
|
||||
public void subscribe<T>(ITag<T> 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);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user