/* We only want to initialize __sched_fifo_min_prio and __sched_fifo_max_prio once. The standard solution would be similar to pthread_once, but then readers would need to use an acquire fence. In this specific case, initialization is comprised of just idempotent writes to two variables that have an initial value of -1. Therefore, we can treat each variable as a separate, at-least-once initialized value. This enables using just relaxed MO loads and stores, but requires that consumers check for initialization of each value that is to be used; see __pthread_tpp_change_priority for an example. */
auto app = m_app_cache.find(app_path); if (app == m_app_cache.end()) { // create a new monitor element m_app_cache.insert_or_assign(app_path, std::make_shared<AppCache>()); } std::lock_guard<std::mutex> lk(app->second->cache_mutex);