mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-12-12 02:52:32 +00:00
f534d3498e
subrepo: subdir: "stratosphere/libstratosphere" merged: "0c5dab80" upstream: origin: "https://github.com/Atmosphere-NX/libstratosphere" branch: "master" commit: "0c5dab80" git-subrepo: version: "0.4.0" origin: "https://github.com/ingydotnet/git-subrepo" commit: "5d6aba9"
47 lines
No EOL
1.7 KiB
C++
47 lines
No EOL
1.7 KiB
C++
/*
|
|
* Copyright (c) 2018-2019 Atmosphère-NX
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
* under the terms and conditions of the GNU General Public License,
|
|
* version 2, as published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
* more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include <mutex>
|
|
#include <switch.h>
|
|
#include <stratosphere.hpp>
|
|
|
|
static HosMutex g_server_query_mutex;
|
|
static HosThread g_server_query_manager_thread;
|
|
static SessionManagerBase *g_server_query_manager = nullptr;
|
|
|
|
static void ServerQueryManagerThreadFunc(void *arg) {
|
|
g_server_query_manager->Process();
|
|
}
|
|
|
|
void RegisterMitmServerQueryHandle(Handle query_h, ServiceObjectHolder &&service) {
|
|
std::scoped_lock<HosMutex> lock(g_server_query_mutex);
|
|
|
|
const bool exists = g_server_query_manager != nullptr;
|
|
if (!exists) {
|
|
/* Create a new waitable manager if it doesn't exist already. */
|
|
static auto s_server_query_manager = WaitableManager(1);
|
|
g_server_query_manager = &s_server_query_manager;
|
|
}
|
|
|
|
/* Add session to the manager. */
|
|
g_server_query_manager->AddSession(query_h, std::move(service));
|
|
|
|
/* If this is our first time, launch thread. */
|
|
if (!exists) {
|
|
R_ASSERT(g_server_query_manager_thread.Initialize(&ServerQueryManagerThreadFunc, nullptr, 0x4000, 27));
|
|
R_ASSERT(g_server_query_manager_thread.Start());
|
|
}
|
|
} |