MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / ThreadFuncImpl

Method ThreadFuncImpl

tensorflow/lite/experimental/ruy/thread_pool.cc:109–133  ·  view source on GitHub ↗

Thread entry point.

Source from the content-addressed store, hash-verified

107 private:
108 // Thread entry point.
109 void ThreadFuncImpl() {
110 ChangeState(State::Ready);
111
112 // Thread main loop
113 while (true) {
114 // In the 'Ready' state, we have nothing to do but to wait until
115 // we switch to another state.
116 const auto& condition = [this]() {
117 return state_.load(std::memory_order_acquire) != State::Ready;
118 };
119 WaitUntil(condition, &state_cond_, &state_mutex_);
120
121 // Act on new state.
122 switch (state_.load(std::memory_order_acquire)) {
123 case State::HasWork:
124 // Got work to do! So do it, and then revert to 'Ready' state.
125 ChangeState(State::Ready);
126 break;
127 case State::ExitAsSoonAsPossible:
128 return;
129 default:
130 abort();
131 }
132 }
133 }
134
135 // The underlying thread.
136 std::unique_ptr<std::thread> thread_;

Callers 1

ThreadFuncMethod · 0.80

Calls 2

WaitUntilFunction · 0.85
loadMethod · 0.45

Tested by

no test coverage detected