| 352 | } |
| 353 | |
| 354 | void ImportBlackboardFromJSON(const nlohmann::json& json, Blackboard& blackboard) |
| 355 | { |
| 356 | for(auto it = json.begin(); it != json.end(); ++it) |
| 357 | { |
| 358 | if(auto res = JsonExporter::get().fromJson(it.value())) |
| 359 | { |
| 360 | auto entry = blackboard.getEntry(it.key()); |
| 361 | if(!entry) |
| 362 | { |
| 363 | blackboard.createEntry(it.key(), res->second); |
| 364 | entry = blackboard.getEntry(it.key()); |
| 365 | } |
| 366 | // Lock entry_mutex before writing to prevent data races (BUG-4 fix). |
| 367 | std::scoped_lock lk(entry->entry_mutex); |
| 368 | entry->value = res->first; |
| 369 | } |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | Blackboard* BT::Blackboard::rootBlackboard() |
| 374 | { |