mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-09 21:51:45 +00:00
tipc: enable named-thread dispatch
This commit is contained in:
parent
d1bc1a5c57
commit
ff5f376c33
3 changed files with 30 additions and 5 deletions
|
@ -28,6 +28,7 @@ namespace ams::impl {
|
|||
|
||||
/* sm. */
|
||||
AMS_DEFINE_SYSTEM_THREAD(-1, sm, Main);
|
||||
AMS_DEFINE_SYSTEM_THREAD(-1, sm, DispatcherThread);
|
||||
|
||||
/* spl. */
|
||||
AMS_DEFINE_SYSTEM_THREAD(-1, spl, Main);
|
||||
|
@ -177,5 +178,5 @@ namespace ams::impl {
|
|||
|
||||
}
|
||||
|
||||
#define AMS_GET_SYSTEM_THREAD_PRIORITY(__AMS_MODULE__, __AMS_THREAD_NAME__) ::ams::impl::SystemThreadDefinition_##__AMS_MODULE__##_##__AMS_THREAD_NAME__.priority
|
||||
#define AMS_GET_SYSTEM_THREAD_NAME(__AMS_MODULE__, __AMS_THREAD_NAME__) ::ams::impl::SystemThreadDefinition_##__AMS_MODULE__##_##__AMS_THREAD_NAME__.name
|
||||
#define AMS_GET_SYSTEM_THREAD_PRIORITY(__AMS_MODULE__, __AMS_THREAD_NAME__) ( ::ams::impl::SystemThreadDefinition_##__AMS_MODULE__##_##__AMS_THREAD_NAME__ ).priority
|
||||
#define AMS_GET_SYSTEM_THREAD_NAME(__AMS_MODULE__, __AMS_THREAD_NAME__) ( ::ams::impl::SystemThreadDefinition_##__AMS_MODULE__##_##__AMS_THREAD_NAME__ ).name
|
||||
|
|
|
@ -379,10 +379,15 @@ namespace ams::tipc {
|
|||
}
|
||||
|
||||
template<size_t Ix>
|
||||
void InitializePortThread(s32 priority) {
|
||||
void InitializePortThread(s32 priority, const char *name) {
|
||||
/* Create the thread. */
|
||||
R_ABORT_UNLESS(os::CreateThread(m_port_threads + Ix, &LoopAutoForPortThreadFunction<Ix>, this, s_port_stacks + Ix, ThreadStackSize, priority));
|
||||
|
||||
/* Set the thread name pointer. */
|
||||
if (name != nullptr) {
|
||||
os::SetThreadNamePointer(m_port_threads + Ix, name);
|
||||
}
|
||||
|
||||
/* Start the thread. */
|
||||
os::StartThread(m_port_threads + Ix);
|
||||
}
|
||||
|
@ -420,7 +425,7 @@ namespace ams::tipc {
|
|||
|
||||
[thread_priority, this]<size_t... Ix>(std::index_sequence<Ix...>) ALWAYS_INLINE_LAMBDA {
|
||||
/* Create all threads. */
|
||||
(this->InitializePortThread<Ix>(thread_priority), ...);
|
||||
(this->InitializePortThread<Ix>(thread_priority, nullptr), ...);
|
||||
}(std::make_index_sequence<NumPorts - 1>());
|
||||
}
|
||||
|
||||
|
@ -428,6 +433,25 @@ namespace ams::tipc {
|
|||
this->LoopAutoForPort<NumPorts - 1>();
|
||||
}
|
||||
|
||||
void LoopAuto(int priority, const char *name) {
|
||||
/* If we have additional threads, create and start them. */
|
||||
if constexpr (NumPorts > 1) {
|
||||
[priority, name, this]<size_t... Ix>(std::index_sequence<Ix...>) ALWAYS_INLINE_LAMBDA {
|
||||
/* Create all threads. */
|
||||
(this->InitializePortThread<Ix>(priority, name), ...);
|
||||
}(std::make_index_sequence<NumPorts - 1>());
|
||||
}
|
||||
|
||||
/* Check current thread. */
|
||||
{
|
||||
AMS_ASSERT(priority == os::GetThreadPriority(os::GetCurrentThread()));
|
||||
/* N does not do: os::SetThreadNamePointer(os::GetCurrentThread(), name); */
|
||||
}
|
||||
|
||||
/* Process for the last port. */
|
||||
this->LoopAutoForPort<NumPorts - 1>();
|
||||
}
|
||||
|
||||
tipc::ServiceObjectBase *AllocateObject(size_t port_index, os::NativeHandle handle, DeferralManagerBaseType &deferral_manager) {
|
||||
/* Check that the port index is valid. */
|
||||
AMS_ABORT_UNLESS(port_index < NumPorts);
|
||||
|
|
|
@ -72,7 +72,7 @@ namespace ams::sm {
|
|||
|
||||
void LoopProcessTipcServer() {
|
||||
/* Loop processing the server on all threads. */
|
||||
g_server_manager.LoopAuto();
|
||||
g_server_manager.LoopAuto(AMS_GET_SYSTEM_THREAD_PRIORITY(sm, DispatcherThread), AMS_GET_SYSTEM_THREAD_NAME(sm, DispatcherThread));
|
||||
}
|
||||
|
||||
void TriggerResume(sm::ServiceName service_name) {
|
||||
|
|
Loading…
Reference in a new issue