Make XObject::GetWaitHandle a protected function

This commit is contained in:
Dr. Chat 2015-12-17 18:32:45 -06:00 committed by Ben Vanik
parent e619e4590c
commit 68f9949829
8 changed files with 22 additions and 18 deletions

View File

@ -36,14 +36,15 @@ class NotifyListener : public XObject {
bool DequeueNotification(XNotificationID* out_id, uint32_t* out_data);
bool DequeueNotification(XNotificationID id, uint32_t* out_data);
xe::threading::WaitHandle* GetWaitHandle() override {
return wait_handle_.get();
}
bool Save(ByteStream* stream) override;
static object_ref<NotifyListener> Restore(KernelState* kernel_state,
ByteStream* stream);
protected:
xe::threading::WaitHandle* GetWaitHandle() override {
return wait_handle_.get();
}
private:
std::unique_ptr<xe::threading::Event> wait_handle_;
xe::global_critical_region global_critical_region_;

View File

@ -37,12 +37,13 @@ class XEvent : public XObject {
int32_t Reset();
void Clear();
xe::threading::WaitHandle* GetWaitHandle() override { return event_.get(); }
bool Save(ByteStream* stream) override;
static object_ref<XEvent> Restore(KernelState* kernel_state,
ByteStream* stream);
protected:
xe::threading::WaitHandle* GetWaitHandle() override { return event_.get(); }
private:
bool manual_reset_ = false;
std::unique_ptr<xe::threading::Event> event_;

View File

@ -104,10 +104,6 @@ class XFile : public XObject {
X_STATUS Write(const void* buffer, size_t buffer_length, size_t byte_offset,
size_t* out_bytes_written, uint32_t apc_context);
xe::threading::WaitHandle* GetWaitHandle() override {
return async_event_.get();
}
void RegisterIOCompletionPort(uint32_t key, object_ref<XIOCompletion> port);
void RemoveIOCompletionPort(uint32_t key);
@ -118,6 +114,10 @@ class XFile : public XObject {
protected:
void NotifyIOCompletionPorts(XIOCompletion::IONotification& notification);
xe::threading::WaitHandle* GetWaitHandle() override {
return async_event_.get();
}
private:
XFile();

View File

@ -30,13 +30,12 @@ class XMutant : public XObject {
X_STATUS ReleaseMutant(uint32_t priority_increment, bool abandon, bool wait);
xe::threading::WaitHandle* GetWaitHandle() override { return mutant_.get(); }
bool Save(ByteStream* stream) override;
static object_ref<XMutant> Restore(KernelState* kernel_state,
ByteStream* stream);
protected:
xe::threading::WaitHandle* GetWaitHandle() override { return mutant_.get(); }
void WaitCallback() override;
private:

View File

@ -187,7 +187,6 @@ class XObject {
static object_ref<T> GetNativeObject(KernelState* kernel_state,
void* native_ptr, int32_t as_type = -1);
virtual xe::threading::WaitHandle* GetWaitHandle() { return nullptr; }
protected:
bool SaveObject(ByteStream* stream);
@ -195,6 +194,7 @@ class XObject {
// Called on successful wait.
virtual void WaitCallback() {}
virtual xe::threading::WaitHandle* GetWaitHandle() { return nullptr; }
// Creates the kernel object for guest code to use. Typically not needed.
uint8_t* CreateNative(uint32_t size);

View File

@ -34,14 +34,15 @@ class XSemaphore : public XObject {
int32_t ReleaseSemaphore(int32_t release_count);
xe::threading::WaitHandle* GetWaitHandle() override {
return semaphore_.get();
}
bool Save(ByteStream* stream) override;
static object_ref<XSemaphore> Restore(KernelState* kernel_state,
ByteStream* stream);
protected:
xe::threading::WaitHandle* GetWaitHandle() override {
return semaphore_.get();
}
private:
std::unique_ptr<xe::threading::Semaphore> semaphore_;
uint32_t maximum_count_ = 0;

View File

@ -181,7 +181,6 @@ class XThread : public XObject {
X_STATUS Delay(uint32_t processor_mode, uint32_t alertable,
uint64_t interval);
xe::threading::WaitHandle* GetWaitHandle() override { return thread_.get(); }
xe::threading::Thread* thread() { return thread_.get(); }
virtual bool Save(ByteStream* stream) override;
@ -204,6 +203,8 @@ class XThread : public XObject {
void DeliverAPCs();
void RundownAPCs();
xe::threading::WaitHandle* GetWaitHandle() override { return thread_.get(); }
CreationParams creation_params_ = {0};
uint32_t thread_id_ = 0;

View File

@ -32,6 +32,7 @@ class XTimer : public XObject {
uint32_t routine_arg, bool resume);
X_STATUS Cancel();
protected:
xe::threading::WaitHandle* GetWaitHandle() override { return timer_.get(); }
private: