MCPcopy Create free account
hub / github.com/alibaba/PhotonLibOS / thread_test_function

Function thread_test_function

thread/test/test.cpp:206–245  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

204thread_local photon::mutex aMutex;
205
206void* thread_test_function(void* arg)
207{
208 LOG_DEBUG(VALUE(CURRENT), " before lock");
209 photon::scoped_lock aLock(aMutex);
210 LOG_DEBUG(VALUE(CURRENT), " after lock");
211
212 uint32_t* result = (uint32_t*)arg;
213
214 *result += 100;
215// for(uint32_t i = 0; i < 100; ++i)
216// {
217// (*result)++;
218// }
219
220 LOG_DEBUG(VALUE(CURRENT), " before sleep");
221 photon::thread_usleep(100);
222 LOG_DEBUG(VALUE(CURRENT), " after sleep");
223
224 *result += 100;
225// for(uint32_t i = 0; i < 100; ++i)
226// {
227// (*result)++;
228// }
229
230 LOG_DEBUG(VALUE(CURRENT), " before yield");
231 photon::thread_yield_to(nullptr);
232 LOG_DEBUG(VALUE(CURRENT), " after yield");
233
234 *result += 100;
235// for(uint32_t i = 0; i < 100; ++i)
236// {
237// (*result)++;
238// }
239
240 aConditionVariable.notify_one();
241 aConditionVariable.notify_all();
242
243 LOG_DEBUG(VALUE(CURRENT), " after notified, about to release lock and exit");
244 return arg;
245}
246
247void wait_for_completion(int vcpu_id = -1)
248{

Callers

nothing calls this directly

Calls 4

thread_yield_toFunction · 0.85
thread_usleepFunction · 0.50
notify_oneMethod · 0.45
notify_allMethod · 0.45

Tested by

no test coverage detected