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

Method start_shutdown

benchmarks/tbb/private_server.cpp:240–261  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

238}
239
240void private_worker::start_shutdown() {
241 state_t s;
242
243 do {
244 s = my_state;
245 __TBB_ASSERT( s!=st_quit, NULL );
246 } while( my_state.compare_and_swap( st_quit, s )!=s );
247 if( s==st_normal || s==st_starting ) {
248 // May have invalidated invariant for sleeping, so wake up the thread.
249 // Note that the notify() here occurs without maintaining invariants for my_slack.
250 // It does not matter, because my_state==st_quit overrides checking of my_slack.
251 my_thread_monitor.notify();
252 // Do not need release handle in st_init state,
253 // because in this case the thread wasn't started yet.
254 // For st_starting release is done at launch site.
255 if (s==st_normal)
256 release_handle(my_handle);
257 } else if( s==st_init ) {
258 // Perform action that otherwise would be performed by associated thread when it quits.
259 my_server.remove_server_ref();
260 }
261}
262
263void private_worker::run() {
264 my_server.propagate_chain_reaction();

Callers 1

Calls 3

remove_server_refMethod · 0.80
compare_and_swapMethod · 0.45
notifyMethod · 0.45

Tested by

no test coverage detected