| 2790 | } |
| 2791 | |
| 2792 | StopReason Task::enter(ThreadState& state, uint64_t nowMicros) { |
| 2793 | BOLT_TEST_ADJUST("bytedance::bolt::exec::Task::enter", &state); |
| 2794 | std::lock_guard<std::timed_mutex> l(mutex_); |
| 2795 | BOLT_CHECK(state.isEnqueued); |
| 2796 | state.isEnqueued = false; |
| 2797 | if (state.isTerminated) { |
| 2798 | return StopReason::kAlreadyTerminated; |
| 2799 | } |
| 2800 | if (state.isOnThread()) { |
| 2801 | return StopReason::kAlreadyOnThread; |
| 2802 | } |
| 2803 | const auto reason = shouldStopLocked(); |
| 2804 | if (reason == StopReason::kTerminate) { |
| 2805 | state.isTerminated = true; |
| 2806 | } |
| 2807 | if (reason == StopReason::kNone) { |
| 2808 | ++numThreads_; |
| 2809 | if (numThreads_ == 1) { |
| 2810 | onThreadSince_ = nowMicros; |
| 2811 | } |
| 2812 | state.setThread(); |
| 2813 | state.hasBlockingFuture = false; |
| 2814 | } |
| 2815 | return reason; |
| 2816 | } |
| 2817 | |
| 2818 | StopReason Task::enterForTerminateLocked(ThreadState& state) { |
| 2819 | if (state.isOnThread() || state.isTerminated) { |
no test coverage detected