thread: Convert ThreadStatus into an enum class
Makes the thread status strongly typed, so implicit conversions can't happen. It also makes it easier to catch mistakes at compile time.
This commit is contained in:
parent
2ba62ec196
commit
5dfa7b74b5
9 changed files with 89 additions and 90 deletions
|
@ -161,8 +161,8 @@ static void ExitProcess() {
|
|||
continue;
|
||||
|
||||
// TODO(Subv): When are the other running/ready threads terminated?
|
||||
ASSERT_MSG(thread->status == THREADSTATUS_WAIT_SYNCH_ANY ||
|
||||
thread->status == THREADSTATUS_WAIT_SYNCH_ALL,
|
||||
ASSERT_MSG(thread->status == ThreadStatus::WaitSynchAny ||
|
||||
thread->status == ThreadStatus::WaitSynchAll,
|
||||
"Exiting processes with non-waiting threads is currently unimplemented");
|
||||
|
||||
thread->Stop();
|
||||
|
@ -283,14 +283,14 @@ static ResultCode WaitSynchronization1(Handle handle, s64 nano_seconds) {
|
|||
|
||||
thread->wait_objects = {object};
|
||||
object->AddWaitingThread(thread);
|
||||
thread->status = THREADSTATUS_WAIT_SYNCH_ANY;
|
||||
thread->status = ThreadStatus::WaitSynchAny;
|
||||
|
||||
// Create an event to wake the thread up after the specified nanosecond delay has passed
|
||||
thread->WakeAfterDelay(nano_seconds);
|
||||
|
||||
thread->wakeup_callback = [](ThreadWakeupReason reason, SharedPtr<Thread> thread,
|
||||
SharedPtr<WaitObject> object) {
|
||||
ASSERT(thread->status == THREADSTATUS_WAIT_SYNCH_ANY);
|
||||
ASSERT(thread->status == ThreadStatus::WaitSynchAny);
|
||||
|
||||
if (reason == ThreadWakeupReason::Timeout) {
|
||||
thread->SetWaitSynchronizationResult(RESULT_TIMEOUT);
|
||||
|
@ -365,7 +365,7 @@ static ResultCode WaitSynchronizationN(s32* out, VAddr handles_address, s32 hand
|
|||
return RESULT_TIMEOUT;
|
||||
|
||||
// Put the thread to sleep
|
||||
thread->status = THREADSTATUS_WAIT_SYNCH_ALL;
|
||||
thread->status = ThreadStatus::WaitSynchAll;
|
||||
|
||||
// Add the thread to each of the objects' waiting threads.
|
||||
for (auto& object : objects) {
|
||||
|
@ -379,7 +379,7 @@ static ResultCode WaitSynchronizationN(s32* out, VAddr handles_address, s32 hand
|
|||
|
||||
thread->wakeup_callback = [](ThreadWakeupReason reason, SharedPtr<Thread> thread,
|
||||
SharedPtr<WaitObject> object) {
|
||||
ASSERT(thread->status == THREADSTATUS_WAIT_SYNCH_ALL);
|
||||
ASSERT(thread->status == ThreadStatus::WaitSynchAll);
|
||||
|
||||
if (reason == ThreadWakeupReason::Timeout) {
|
||||
thread->SetWaitSynchronizationResult(RESULT_TIMEOUT);
|
||||
|
@ -421,7 +421,7 @@ static ResultCode WaitSynchronizationN(s32* out, VAddr handles_address, s32 hand
|
|||
return RESULT_TIMEOUT;
|
||||
|
||||
// Put the thread to sleep
|
||||
thread->status = THREADSTATUS_WAIT_SYNCH_ANY;
|
||||
thread->status = ThreadStatus::WaitSynchAny;
|
||||
|
||||
// Add the thread to each of the objects' waiting threads.
|
||||
for (std::size_t i = 0; i < objects.size(); ++i) {
|
||||
|
@ -439,7 +439,7 @@ static ResultCode WaitSynchronizationN(s32* out, VAddr handles_address, s32 hand
|
|||
|
||||
thread->wakeup_callback = [](ThreadWakeupReason reason, SharedPtr<Thread> thread,
|
||||
SharedPtr<WaitObject> object) {
|
||||
ASSERT(thread->status == THREADSTATUS_WAIT_SYNCH_ANY);
|
||||
ASSERT(thread->status == ThreadStatus::WaitSynchAny);
|
||||
|
||||
if (reason == ThreadWakeupReason::Timeout) {
|
||||
thread->SetWaitSynchronizationResult(RESULT_TIMEOUT);
|
||||
|
@ -578,7 +578,7 @@ static ResultCode ReplyAndReceive(s32* index, VAddr handles_address, s32 handle_
|
|||
// No objects were ready to be acquired, prepare to suspend the thread.
|
||||
|
||||
// Put the thread to sleep
|
||||
thread->status = THREADSTATUS_WAIT_SYNCH_ANY;
|
||||
thread->status = ThreadStatus::WaitSynchAny;
|
||||
|
||||
// Add the thread to each of the objects' waiting threads.
|
||||
for (std::size_t i = 0; i < objects.size(); ++i) {
|
||||
|
@ -590,7 +590,7 @@ static ResultCode ReplyAndReceive(s32* index, VAddr handles_address, s32 handle_
|
|||
|
||||
thread->wakeup_callback = [](ThreadWakeupReason reason, SharedPtr<Thread> thread,
|
||||
SharedPtr<WaitObject> object) {
|
||||
ASSERT(thread->status == THREADSTATUS_WAIT_SYNCH_ANY);
|
||||
ASSERT(thread->status == ThreadStatus::WaitSynchAny);
|
||||
ASSERT(reason == ThreadWakeupReason::Signal);
|
||||
|
||||
ResultCode result = RESULT_SUCCESS;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue