forked from ShuriZma/suyu
1
0
Fork 0

kernel/wait_object: Make ShouldWait() take thread members by pointer-to-const

Given this is intended as a querying function, it doesn't make sense to
allow the implementer to modify the state of the given thread.
This commit is contained in:
Lioncash 2019-04-01 18:19:42 -04:00
parent 2d70c30fb2
commit 20cc0b8d3c
11 changed files with 11 additions and 11 deletions

View File

@ -247,7 +247,7 @@ void Process::Acquire(Thread* thread) {
ASSERT_MSG(!ShouldWait(thread), "Object unavailable!"); ASSERT_MSG(!ShouldWait(thread), "Object unavailable!");
} }
bool Process::ShouldWait(Thread* thread) const { bool Process::ShouldWait(const Thread* thread) const {
return !is_signaled; return !is_signaled;
} }

View File

@ -237,7 +237,7 @@ private:
~Process() override; ~Process() override;
/// Checks if the specified thread should wait until this process is available. /// Checks if the specified thread should wait until this process is available.
bool ShouldWait(Thread* thread) const override; bool ShouldWait(const Thread* thread) const override;
/// Acquires/locks this process for the specified thread if it's available. /// Acquires/locks this process for the specified thread if it's available.
void Acquire(Thread* thread) override; void Acquire(Thread* thread) override;

View File

@ -14,7 +14,7 @@ namespace Kernel {
ReadableEvent::ReadableEvent(KernelCore& kernel) : WaitObject{kernel} {} ReadableEvent::ReadableEvent(KernelCore& kernel) : WaitObject{kernel} {}
ReadableEvent::~ReadableEvent() = default; ReadableEvent::~ReadableEvent() = default;
bool ReadableEvent::ShouldWait(Thread* thread) const { bool ReadableEvent::ShouldWait(const Thread* thread) const {
return !signaled; return !signaled;
} }

View File

@ -36,7 +36,7 @@ public:
return HANDLE_TYPE; return HANDLE_TYPE;
} }
bool ShouldWait(Thread* thread) const override; bool ShouldWait(const Thread* thread) const override;
void Acquire(Thread* thread) override; void Acquire(Thread* thread) override;
/// Unconditionally clears the readable event's state. /// Unconditionally clears the readable event's state.

View File

@ -30,7 +30,7 @@ void ServerPort::AppendPendingSession(SharedPtr<ServerSession> pending_session)
pending_sessions.push_back(std::move(pending_session)); pending_sessions.push_back(std::move(pending_session));
} }
bool ServerPort::ShouldWait(Thread* thread) const { bool ServerPort::ShouldWait(const Thread* thread) const {
// If there are no pending sessions, we wait until a new one is added. // If there are no pending sessions, we wait until a new one is added.
return pending_sessions.empty(); return pending_sessions.empty();
} }

View File

@ -75,7 +75,7 @@ public:
/// waiting to be accepted by this port. /// waiting to be accepted by this port.
void AppendPendingSession(SharedPtr<ServerSession> pending_session); void AppendPendingSession(SharedPtr<ServerSession> pending_session);
bool ShouldWait(Thread* thread) const override; bool ShouldWait(const Thread* thread) const override;
void Acquire(Thread* thread) override; void Acquire(Thread* thread) override;
private: private:

View File

@ -46,7 +46,7 @@ ResultVal<SharedPtr<ServerSession>> ServerSession::Create(KernelCore& kernel, st
return MakeResult(std::move(server_session)); return MakeResult(std::move(server_session));
} }
bool ServerSession::ShouldWait(Thread* thread) const { bool ServerSession::ShouldWait(const Thread* thread) const {
// Closed sessions should never wait, an error will be returned from svcReplyAndReceive. // Closed sessions should never wait, an error will be returned from svcReplyAndReceive.
if (parent->client == nullptr) if (parent->client == nullptr)
return false; return false;

View File

@ -82,7 +82,7 @@ public:
*/ */
ResultCode HandleSyncRequest(SharedPtr<Thread> thread); ResultCode HandleSyncRequest(SharedPtr<Thread> thread);
bool ShouldWait(Thread* thread) const override; bool ShouldWait(const Thread* thread) const override;
void Acquire(Thread* thread) override; void Acquire(Thread* thread) override;

View File

@ -28,7 +28,7 @@
namespace Kernel { namespace Kernel {
bool Thread::ShouldWait(Thread* thread) const { bool Thread::ShouldWait(const Thread* thread) const {
return status != ThreadStatus::Dead; return status != ThreadStatus::Dead;
} }

View File

@ -111,7 +111,7 @@ public:
return HANDLE_TYPE; return HANDLE_TYPE;
} }
bool ShouldWait(Thread* thread) const override; bool ShouldWait(const Thread* thread) const override;
void Acquire(Thread* thread) override; void Acquire(Thread* thread) override;
/** /**

View File

@ -24,7 +24,7 @@ public:
* @param thread The thread about which we're deciding. * @param thread The thread about which we're deciding.
* @return True if the current thread should wait due to this object being unavailable * @return True if the current thread should wait due to this object being unavailable
*/ */
virtual bool ShouldWait(Thread* thread) const = 0; virtual bool ShouldWait(const Thread* thread) const = 0;
/// Acquire/lock the object for the specified thread if it is available /// Acquire/lock the object for the specified thread if it is available
virtual void Acquire(Thread* thread) = 0; virtual void Acquire(Thread* thread) = 0;