Replace the namespace-app set; reports add/remove counts for logging.
| 590 | |
| 591 | // Replace the namespace-app set; reports add/remove counts for logging. |
| 592 | void SetNamespaceApps(const uint32_t* appIds, uint32_t count, |
| 593 | size_t* outAdded, size_t* outRemoved) { |
| 594 | std::unordered_set<uint32_t> next; |
| 595 | next.reserve(count); |
| 596 | for (uint32_t i = 0; i < count; ++i) { |
| 597 | if (appIds[i] != 0) next.insert(appIds[i]); |
| 598 | } |
| 599 | std::lock_guard<std::mutex> lock(g_namespaceAppsMutex); |
| 600 | if (outAdded) { |
| 601 | size_t added = 0; |
| 602 | for (uint32_t id : next) |
| 603 | if (g_namespaceApps.count(id) == 0) ++added; |
| 604 | *outAdded = added; |
| 605 | } |
| 606 | if (outRemoved) { |
| 607 | size_t removed = 0; |
| 608 | for (uint32_t id : g_namespaceApps) |
| 609 | if (next.count(id) == 0) ++removed; |
| 610 | *outRemoved = removed; |
| 611 | } |
| 612 | g_namespaceApps = std::move(next); |
| 613 | } |
| 614 | |
| 615 | static uintptr_t FindCurrentUser(); |
| 616 |