MCPcopy Create free account
hub / github.com/cameron314/concurrentqueue / wake_or_launch

Method wake_or_launch

benchmarks/tbb/private_server.cpp:294–318  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

292}
293
294inline void private_worker::wake_or_launch() {
295 if( my_state==st_init && my_state.compare_and_swap( st_starting, st_init )==st_init ) {
296 // after this point, remove_server_ref() must be done by created thread
297#if USE_WINTHREAD
298 my_handle = thread_monitor::launch( thread_routine, this, my_server.my_stack_size, &this->my_index );
299#elif USE_PTHREAD
300 {
301 affinity_helper fpa;
302 fpa.protect_affinity_mask();
303 my_handle = thread_monitor::launch( thread_routine, this, my_server.my_stack_size );
304 // Implicit destruction of fpa resets original affinity mask.
305 }
306#endif /* USE_PTHREAD */
307 state_t s = my_state.compare_and_swap( st_normal, st_starting );
308 if (st_starting != s) {
309 // Do shutdown during startup. my_handle can't be released
310 // by start_shutdown, because my_handle value might be not set yet
311 // at time of transition from st_starting to st_quit.
312 __TBB_ASSERT( s==st_quit, NULL );
313 release_handle(my_handle);
314 }
315 }
316 else
317 my_thread_monitor.notify();
318}
319
320//------------------------------------------------------------------------
321// Methods of private_server

Callers 1

wake_someMethod · 0.80

Calls 3

compare_and_swapMethod · 0.45
protect_affinity_maskMethod · 0.45
notifyMethod · 0.45

Tested by

no test coverage detected