hle: service: Add option for service interfaces to create or use the default thread.
This commit is contained in:
parent
864523327f
commit
bf1750664c
5 changed files with 29 additions and 11 deletions
|
@ -24,8 +24,15 @@
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
SessionRequestHandler::SessionRequestHandler(KernelCore& kernel_, const char* service_name_)
|
SessionRequestHandler::SessionRequestHandler(KernelCore& kernel_, const char* service_name_,
|
||||||
: kernel{kernel_}, service_thread{kernel.CreateServiceThread(service_name_)} {}
|
ServiceThreadType thread_type)
|
||||||
|
: kernel{kernel_} {
|
||||||
|
if (thread_type == ServiceThreadType::CreateNew) {
|
||||||
|
service_thread = kernel.CreateServiceThread(service_name_);
|
||||||
|
} else {
|
||||||
|
service_thread = kernel.GetDefaultServiceThread();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SessionRequestHandler::~SessionRequestHandler() {
|
SessionRequestHandler::~SessionRequestHandler() {
|
||||||
kernel.ReleaseServiceThread(service_thread);
|
kernel.ReleaseServiceThread(service_thread);
|
||||||
|
|
|
@ -33,6 +33,11 @@ namespace Service {
|
||||||
class ServiceFrameworkBase;
|
class ServiceFrameworkBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum class ServiceThreadType {
|
||||||
|
Default,
|
||||||
|
CreateNew,
|
||||||
|
};
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
class Domain;
|
class Domain;
|
||||||
|
@ -57,7 +62,8 @@ enum class ThreadWakeupReason;
|
||||||
*/
|
*/
|
||||||
class SessionRequestHandler : public std::enable_shared_from_this<SessionRequestHandler> {
|
class SessionRequestHandler : public std::enable_shared_from_this<SessionRequestHandler> {
|
||||||
public:
|
public:
|
||||||
SessionRequestHandler(KernelCore& kernel, const char* service_name_);
|
SessionRequestHandler(KernelCore& kernel_, const char* service_name_,
|
||||||
|
ServiceThreadType thread_type);
|
||||||
virtual ~SessionRequestHandler();
|
virtual ~SessionRequestHandler();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -91,8 +91,9 @@ namespace Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
ServiceFrameworkBase::ServiceFrameworkBase(Core::System& system_, const char* service_name_,
|
ServiceFrameworkBase::ServiceFrameworkBase(Core::System& system_, const char* service_name_,
|
||||||
u32 max_sessions_, InvokerFn* handler_invoker_)
|
ServiceThreadType thread_type, u32 max_sessions_,
|
||||||
: SessionRequestHandler(system_.Kernel(), service_name_), system{system_},
|
InvokerFn* handler_invoker_)
|
||||||
|
: SessionRequestHandler(system_.Kernel(), service_name_, thread_type), system{system_},
|
||||||
service_name{service_name_}, max_sessions{max_sessions_}, handler_invoker{handler_invoker_} {}
|
service_name{service_name_}, max_sessions{max_sessions_}, handler_invoker{handler_invoker_} {}
|
||||||
|
|
||||||
ServiceFrameworkBase::~ServiceFrameworkBase() {
|
ServiceFrameworkBase::~ServiceFrameworkBase() {
|
||||||
|
|
|
@ -114,7 +114,8 @@ private:
|
||||||
Kernel::HLERequestContext& ctx);
|
Kernel::HLERequestContext& ctx);
|
||||||
|
|
||||||
explicit ServiceFrameworkBase(Core::System& system_, const char* service_name_,
|
explicit ServiceFrameworkBase(Core::System& system_, const char* service_name_,
|
||||||
u32 max_sessions_, InvokerFn* handler_invoker_);
|
ServiceThreadType thread_type, u32 max_sessions_,
|
||||||
|
InvokerFn* handler_invoker_);
|
||||||
~ServiceFrameworkBase() override;
|
~ServiceFrameworkBase() override;
|
||||||
|
|
||||||
void RegisterHandlersBase(const FunctionInfoBase* functions, std::size_t n);
|
void RegisterHandlersBase(const FunctionInfoBase* functions, std::size_t n);
|
||||||
|
@ -178,12 +179,15 @@ protected:
|
||||||
*
|
*
|
||||||
* @param system_ The system context to construct this service under.
|
* @param system_ The system context to construct this service under.
|
||||||
* @param service_name_ Name of the service.
|
* @param service_name_ Name of the service.
|
||||||
* @param max_sessions_ Maximum number of sessions that can be
|
* @param thread_type Specifies the thread type for this service. If this is set to CreateNew,
|
||||||
* connected to this service at the same time.
|
* it creates a new thread for it, otherwise this uses the default thread.
|
||||||
|
* @param max_sessions_ Maximum number of sessions that can be connected to this service at the
|
||||||
|
* same time.
|
||||||
*/
|
*/
|
||||||
explicit ServiceFramework(Core::System& system_, const char* service_name_,
|
explicit ServiceFramework(Core::System& system_, const char* service_name_,
|
||||||
|
ServiceThreadType thread_type = ServiceThreadType::Default,
|
||||||
u32 max_sessions_ = ServerSessionCountMax)
|
u32 max_sessions_ = ServerSessionCountMax)
|
||||||
: ServiceFrameworkBase(system_, service_name_, max_sessions_, Invoker) {}
|
: ServiceFrameworkBase(system_, service_name_, thread_type, max_sessions_, Invoker) {}
|
||||||
|
|
||||||
/// Registers handlers in the service.
|
/// Registers handlers in the service.
|
||||||
template <std::size_t N>
|
template <std::size_t N>
|
||||||
|
|
|
@ -206,7 +206,7 @@ void SM::UnregisterService(Kernel::HLERequestContext& ctx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SM::SM(ServiceManager& service_manager_, Core::System& system_)
|
SM::SM(ServiceManager& service_manager_, Core::System& system_)
|
||||||
: ServiceFramework{system_, "sm:", 4},
|
: ServiceFramework{system_, "sm:", ServiceThreadType::Default, 4},
|
||||||
service_manager{service_manager_}, kernel{system_.Kernel()} {
|
service_manager{service_manager_}, kernel{system_.Kernel()} {
|
||||||
RegisterHandlers({
|
RegisterHandlers({
|
||||||
{0, &SM::Initialize, "Initialize"},
|
{0, &SM::Initialize, "Initialize"},
|
||||||
|
|
Loading…
Reference in a new issue