| 116 | } |
| 117 | |
| 118 | void ServiceThread::waitStatus(Status target, uint32_t fatal_timeout) SKR_NOEXCEPT |
| 119 | { |
| 120 | SkrZoneScopedN("waitStatus"); |
| 121 | |
| 122 | const auto tid = skr_current_thread_id(); |
| 123 | if (tid == t.get_id()) |
| 124 | { |
| 125 | SKR_LOG_FATAL(u8"service_thread: dead lock detected!"); |
| 126 | SKR_ASSERT((tid != t.get_id()) && "service_thread: dead lock detected!"); |
| 127 | } |
| 128 | |
| 129 | const auto current = get_status(); |
| 130 | if (const auto earlyCheck = (current == target)) |
| 131 | return; |
| 132 | |
| 133 | if ((target == kStatusRunning) && (current != kStatusStopped)) |
| 134 | { |
| 135 | SKR_LOG_FATAL(u8"service_thread: must wait from a waking service!(current status: %d)", current); |
| 136 | SKR_ASSERT(current == kStatusStopped); |
| 137 | } |
| 138 | else if ((target == kStatusStopped) && (current != kStatusRunning)) |
| 139 | { |
| 140 | SKR_LOG_FATAL(u8"service_thread: must wait from a stopping service!(current status: %d)", current); |
| 141 | SKR_ASSERT(current == kStatusRunning); |
| 142 | } |
| 143 | else if ((target == kStatusExitted) && (current != kStatusStopped)) |
| 144 | { |
| 145 | SKR_LOG_FATAL(u8"service_thread: must wait from a exiting service!(current status: %d)", current); |
| 146 | SKR_ASSERT(current == kStatusStopped); |
| 147 | } |
| 148 | |
| 149 | if (!wait_timeout<u8"WaitStatus">([&] { return get_status() == target; }, fatal_timeout)) |
| 150 | SKR_LOG_FATAL(u8"service_thread: waitStatus timeout! current status: %d, target status: %d", current, target); |
| 151 | } |
| 152 | |
| 153 | ServiceThread::Status ServiceThread::takeAction() SKR_NOEXCEPT |
| 154 | { |
nothing calls this directly
no test coverage detected