HLE/IPC: HLEContext can memorize the client thread and use it for SleepClientThread

This reduces the boilerplate that services have to write out the current thread explicitly. Using current thread instead of client thread is also semantically incorrect, and will be a problem when we implement multicore (at which time there will be multiple current threads)
This commit is contained in:
Weiyi Wang 2019-04-02 12:30:03 -04:00
parent daeba65fb4
commit f565ea80f0
8 changed files with 16 additions and 22 deletions

View file

@ -71,8 +71,7 @@ void File::Read(Kernel::HLERequestContext& ctx) {
rb.PushMappedBuffer(buffer);
std::chrono::nanoseconds read_timeout_ns{backend->GetReadDelayNs(length)};
ctx.SleepClientThread(Kernel::SharedFrom(system.Kernel().GetThreadManager().GetCurrentThread()),
"file::read", read_timeout_ns,
ctx.SleepClientThread("file::read", read_timeout_ns,
[](std::shared_ptr<Kernel::Thread> /*thread*/,
Kernel::HLERequestContext& /*ctx*/,
Kernel::ThreadWakeupReason /*reason*/) {

View file

@ -71,8 +71,7 @@ void FS_USER::OpenFile(Kernel::HLERequestContext& ctx) {
LOG_ERROR(Service_FS, "failed to get a handle for file {}", file_path.DebugStr());
}
ctx.SleepClientThread(Kernel::SharedFrom(system.Kernel().GetThreadManager().GetCurrentThread()),
"fs_user::open", open_timeout_ns,
ctx.SleepClientThread("fs_user::open", open_timeout_ns,
[](std::shared_ptr<Kernel::Thread> /*thread*/,
Kernel::HLERequestContext& /*ctx*/,
Kernel::ThreadWakeupReason /*reason*/) {
@ -130,8 +129,7 @@ void FS_USER::OpenFileDirectly(Kernel::HLERequestContext& ctx) {
file_path.DebugStr(), mode.hex, attributes);
}
ctx.SleepClientThread(Kernel::SharedFrom(system.Kernel().GetThreadManager().GetCurrentThread()),
"fs_user::open_directly", open_timeout_ns,
ctx.SleepClientThread("fs_user::open_directly", open_timeout_ns,
[](std::shared_ptr<Kernel::Thread> /*thread*/,
Kernel::HLERequestContext& /*ctx*/,
Kernel::ThreadWakeupReason /*reason*/) {

View file

@ -1179,7 +1179,6 @@ void NWM_UDS::ConnectToNetwork(Kernel::HLERequestContext& ctx, u16 command_id,
static constexpr std::chrono::nanoseconds UDSConnectionTimeout{300000000};
connection_event = ctx.SleepClientThread(
Kernel::SharedFrom(system.Kernel().GetThreadManager().GetCurrentThread()),
"uds::ConnectToNetwork", UDSConnectionTimeout,
[command_id](std::shared_ptr<Kernel::Thread> thread, Kernel::HLERequestContext& ctx,
Kernel::ThreadWakeupReason reason) {

View file

@ -127,9 +127,8 @@ void SRV::GetServiceHandle(Kernel::HLERequestContext& ctx) {
if (client_port.Failed()) {
if (wait_until_available && client_port.Code() == ERR_SERVICE_NOT_REGISTERED) {
LOG_INFO(Service_SRV, "called service={} delayed", name);
std::shared_ptr<Kernel::Event> get_service_handle_event = ctx.SleepClientThread(
Kernel::SharedFrom(system.Kernel().GetThreadManager().GetCurrentThread()),
"GetServiceHandle", std::chrono::nanoseconds(-1), get_handle);
std::shared_ptr<Kernel::Event> get_service_handle_event =
ctx.SleepClientThread("GetServiceHandle", std::chrono::nanoseconds(-1), get_handle);
get_service_handle_delayed_map[name] = std::move(get_service_handle_event);
return;
} else {