forked from suyu/suyu
hle_ipc: Refactor SleepClientThread to avoid ReadableEvent
This commit is contained in:
parent
a342bcc9b1
commit
170d707850
9 changed files with 14 additions and 14 deletions
|
@ -39,7 +39,7 @@ void SessionRequestHandler::ClientDisconnected(const SharedPtr<ServerSession>& s
|
||||||
|
|
||||||
SharedPtr<WritableEvent> HLERequestContext::SleepClientThread(
|
SharedPtr<WritableEvent> HLERequestContext::SleepClientThread(
|
||||||
SharedPtr<Thread> thread, const std::string& reason, u64 timeout, WakeupCallback&& callback,
|
SharedPtr<Thread> thread, const std::string& reason, u64 timeout, WakeupCallback&& callback,
|
||||||
SharedPtr<WritableEvent> writable_event, SharedPtr<ReadableEvent> readable_event) {
|
SharedPtr<WritableEvent> writable_event) {
|
||||||
// Put the client thread to sleep until the wait event is signaled or the timeout expires.
|
// Put the client thread to sleep until the wait event is signaled or the timeout expires.
|
||||||
thread->SetWakeupCallback([context = *this, callback](
|
thread->SetWakeupCallback([context = *this, callback](
|
||||||
ThreadWakeupReason reason, SharedPtr<Thread> thread,
|
ThreadWakeupReason reason, SharedPtr<Thread> thread,
|
||||||
|
@ -51,14 +51,14 @@ SharedPtr<WritableEvent> HLERequestContext::SleepClientThread(
|
||||||
});
|
});
|
||||||
|
|
||||||
auto& kernel = Core::System::GetInstance().Kernel();
|
auto& kernel = Core::System::GetInstance().Kernel();
|
||||||
if (!writable_event || !readable_event) {
|
if (!writable_event) {
|
||||||
// Create event if not provided
|
// Create event if not provided
|
||||||
const auto pair = WritableEvent::CreateEventPair(kernel, Kernel::ResetType::OneShot,
|
const auto pair = WritableEvent::CreateEventPair(kernel, Kernel::ResetType::OneShot,
|
||||||
"HLE Pause Event: " + reason);
|
"HLE Pause Event: " + reason);
|
||||||
writable_event = pair.writable;
|
writable_event = pair.writable;
|
||||||
readable_event = pair.readable;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto readable_event{writable_event->GetReadableEvent()};
|
||||||
writable_event->Clear();
|
writable_event->Clear();
|
||||||
thread->SetStatus(ThreadStatus::WaitHLEEvent);
|
thread->SetStatus(ThreadStatus::WaitHLEEvent);
|
||||||
thread->SetWaitObjects({readable_event});
|
thread->SetWaitObjects({readable_event});
|
||||||
|
|
|
@ -122,13 +122,11 @@ public:
|
||||||
* was called.
|
* was called.
|
||||||
* @param writable_event Event to use to wake up the thread. If unspecified, an event will be
|
* @param writable_event Event to use to wake up the thread. If unspecified, an event will be
|
||||||
* created.
|
* created.
|
||||||
* @param readable_event Event to be bound to the thread to wake up upon.
|
|
||||||
* @returns Event that when signaled will resume the thread and call the callback function.
|
* @returns Event that when signaled will resume the thread and call the callback function.
|
||||||
*/
|
*/
|
||||||
SharedPtr<WritableEvent> SleepClientThread(SharedPtr<Thread> thread, const std::string& reason,
|
SharedPtr<WritableEvent> SleepClientThread(SharedPtr<Thread> thread, const std::string& reason,
|
||||||
u64 timeout, WakeupCallback&& callback,
|
u64 timeout, WakeupCallback&& callback,
|
||||||
SharedPtr<WritableEvent> writable_event = nullptr,
|
SharedPtr<WritableEvent> writable_event = nullptr);
|
||||||
SharedPtr<ReadableEvent> readable_event = nullptr);
|
|
||||||
|
|
||||||
/// Populates this context with data from the requesting process/thread.
|
/// Populates this context with data from the requesting process/thread.
|
||||||
ResultCode PopulateFromIncomingCommandBuffer(const HandleTable& handle_table,
|
ResultCode PopulateFromIncomingCommandBuffer(const HandleTable& handle_table,
|
||||||
|
|
|
@ -17,11 +17,9 @@
|
||||||
#include "core/hle/kernel/handle_table.h"
|
#include "core/hle/kernel/handle_table.h"
|
||||||
#include "core/hle/kernel/kernel.h"
|
#include "core/hle/kernel/kernel.h"
|
||||||
#include "core/hle/kernel/process.h"
|
#include "core/hle/kernel/process.h"
|
||||||
#include "core/hle/kernel/readable_event.h"
|
|
||||||
#include "core/hle/kernel/resource_limit.h"
|
#include "core/hle/kernel/resource_limit.h"
|
||||||
#include "core/hle/kernel/thread.h"
|
#include "core/hle/kernel/thread.h"
|
||||||
#include "core/hle/kernel/timer.h"
|
#include "core/hle/kernel/timer.h"
|
||||||
#include "core/hle/kernel/writable_event.h"
|
|
||||||
#include "core/hle/lock.h"
|
#include "core/hle/lock.h"
|
||||||
#include "core/hle/result.h"
|
#include "core/hle/result.h"
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,10 @@ EventPair WritableEvent::CreateEventPair(KernelCore& kernel, ResetType reset_typ
|
||||||
return {std::move(readable_event), std::move(writable_event)};
|
return {std::move(readable_event), std::move(writable_event)};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SharedPtr<ReadableEvent> WritableEvent::GetReadableEvent() const {
|
||||||
|
return readable;
|
||||||
|
}
|
||||||
|
|
||||||
ResetType WritableEvent::GetResetType() const {
|
ResetType WritableEvent::GetResetType() const {
|
||||||
return readable->reset_type;
|
return readable->reset_type;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,8 @@ public:
|
||||||
return HANDLE_TYPE;
|
return HANDLE_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SharedPtr<ReadableEvent> GetReadableEvent() const;
|
||||||
|
|
||||||
ResetType GetResetType() const;
|
ResetType GetResetType() const;
|
||||||
|
|
||||||
void Signal();
|
void Signal();
|
||||||
|
|
|
@ -302,6 +302,7 @@ void ISelfController::GetLibraryAppletLaunchableEvent(Kernel::HLERequestContext&
|
||||||
IPC::ResponseBuilder rb{ctx, 2, 1};
|
IPC::ResponseBuilder rb{ctx, 2, 1};
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
rb.PushCopyObjects(launchable_event.readable);
|
rb.PushCopyObjects(launchable_event.readable);
|
||||||
|
}
|
||||||
|
|
||||||
void ISelfController::SetScreenShotImageOrientation(Kernel::HLERequestContext& ctx) {
|
void ISelfController::SetScreenShotImageOrientation(Kernel::HLERequestContext& ctx) {
|
||||||
LOG_WARNING(Service_AM, "(STUBBED) called");
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
||||||
|
|
|
@ -8,14 +8,10 @@
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include "common/swap.h"
|
#include "common/swap.h"
|
||||||
#include "core/hle/kernel/kernel.h"
|
#include "core/hle/kernel/kernel.h"
|
||||||
|
#include "core/hle/kernel/writable_event.h"
|
||||||
|
|
||||||
union ResultCode;
|
union ResultCode;
|
||||||
|
|
||||||
namespace Kernel {
|
|
||||||
class ReadableEvent;
|
|
||||||
class WritableEvent;
|
|
||||||
} // namespace Kernel
|
|
||||||
|
|
||||||
namespace Service::AM {
|
namespace Service::AM {
|
||||||
|
|
||||||
class IStorage;
|
class IStorage;
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include "core/hle/kernel/readable_event.h"
|
||||||
#include "core/hle/kernel/writable_event.h"
|
#include "core/hle/kernel/writable_event.h"
|
||||||
#include "core/hle/service/service.h"
|
#include "core/hle/service/service.h"
|
||||||
|
|
||||||
|
|
|
@ -548,7 +548,7 @@ private:
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
},
|
},
|
||||||
buffer_queue->GetWritableBufferWaitEvent(), buffer_queue->GetBufferWaitEvent());
|
buffer_queue->GetWritableBufferWaitEvent());
|
||||||
}
|
}
|
||||||
} else if (transaction == TransactionId::RequestBuffer) {
|
} else if (transaction == TransactionId::RequestBuffer) {
|
||||||
IGBPRequestBufferRequestParcel request{ctx.ReadBuffer()};
|
IGBPRequestBufferRequestParcel request{ctx.ReadBuffer()};
|
||||||
|
|
Loading…
Reference in a new issue