! * Starts the thread running. Will call the user provided Run() * once it's ready (unless the thread was already asked to exit). * * Returns true on success, false (with errno set) on failure. */
| 163 | * Returns true on success, false (with errno set) on failure. |
| 164 | */ |
| 165 | bool Start() { |
| 166 | // Establish process-wide signal catching, if that isn't |
| 167 | // yet done. The signal handler will interrupt system calls. |
| 168 | if (!CatchExitSignal()) { |
| 169 | return false; |
| 170 | } |
| 171 | |
| 172 | // If the thread isn't in pristine state, this is an error. |
| 173 | if (state_ != ThreadState::kNotStarted) { |
| 174 | errno = EINVAL; |
| 175 | return false; |
| 176 | } |
| 177 | |
| 178 | assert(!thread_.joinable()); |
| 179 | AssertNoKnockThread(); |
| 180 | |
| 181 | state_ = ThreadState::kStarting; |
| 182 | thread_ = std::thread(RunInThread, this, reliable_); |
| 183 | |
| 184 | return true; |
| 185 | } |
| 186 | |
| 187 | /* |
| 188 | * Requests that the thread, if started, terminate. Optionally |
no test coverage detected