Make Sendable setters synchronous (#1799)

Instead of being called asynchronously by NetworkTables, they are now called by updateValues() synchronously with the main loop, just like the getters.
This commit is contained in:
Oblarg
2019-08-03 18:08:06 -04:00
committed by Peter Johnson
parent c67a488a09
commit fbe67c90c8
8 changed files with 194 additions and 23 deletions

View File

@@ -254,10 +254,17 @@ std::shared_ptr<nt::Value> SmartDashboard::GetValue(wpi::StringRef keyName) {
return Singleton::GetInstance().table->GetEntry(keyName).GetValue();
}
detail::ListenerExecutor SmartDashboard::listenerExecutor;
void SmartDashboard::PostListenerTask(std::function<void()> task) {
listenerExecutor.Execute(task);
}
void SmartDashboard::UpdateValues() {
auto& inst = Singleton::GetInstance();
std::scoped_lock lock(inst.tablesToDataMutex);
for (auto& i : inst.tablesToData) {
i.getValue().builder.UpdateTable();
}
listenerExecutor.RunListenerTasks();
}