Putting guest thread to sleep inside handler

This commit is contained in:
visha
2018-02-13 22:24:30 +05:30
parent be5ba4d952
commit b42faa8f85
4 changed files with 65 additions and 4 deletions

View File

@@ -7,6 +7,7 @@
#include <array>
#include <memory>
#include <vector>
#include <string>
#include <boost/container/small_vector.hpp>
#include "common/common_types.h"
#include "common/swap.h"
@@ -24,6 +25,8 @@ class Domain;
class HandleTable;
class HLERequestContext;
class Process;
class Thread;
class Event;
/**
* Interface implemented by HLE Session handlers.
@@ -102,6 +105,23 @@ public:
return server_session;
}
using WakeupCallback = std::function<void(SharedPtr<Thread> thread, HLERequestContext& context,
ThreadWakeupReason reason)>;
/*
* Puts the specified guest thread to sleep until the returned event is signaled or until the
* specified timeout expires.
* @param thread Thread to be put to sleep.
* @param reason Reason for pausing the thread, to be used for debugging purposes.
* @param timeout Timeout in nanoseconds after which the thread will be awoken and the callback
* invoked with a Timeout reason.
* @param callback Callback to be invoked when the thread is resumed. This callback must write
* the entire command response once again, regardless of the state of it before this function
* was called.
* @returns Event that when signaled will resume the thread and call the callback function.
*/
SharedPtr<Event> SleepClientThread(SharedPtr<Thread> thread, const std::string& reason,
u64 timeout, WakeupCallback&& callback);
void ParseCommandBuffer(u32_le* src_cmdbuf, bool incoming);
/// Populates this context with data from the requesting process/thread.