MCPcopy Create free account
hub / github.com/davisking/dlib / destruct_if_ready

Method destruct_if_ready

dlib/threads/threads_kernel_shared.cpp:117–142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115// ----------------------------------------------------------------------------------------
116
117 void threader::
118 destruct_if_ready (
119 )
120 {
121 if (do_not_ever_destruct)
122 return;
123
124 data_mutex.lock();
125
126 // if there aren't any active threads, just maybe some sitting around
127 // in the pool then just destroy the threader
128 if (total_count == pool_count)
129 {
130 destruct = true;
131 data_ready.broadcast();
132 data_mutex.unlock();
133 delete this;
134 }
135 else
136 {
137 // There are still some user threads running so there isn't
138 // much we can really do. Just let the program end without
139 // cleaning up threading resources.
140 data_mutex.unlock();
141 }
142 }
143
144// ----------------------------------------------------------------------------------------
145

Callers

nothing calls this directly

Calls 3

lockMethod · 0.45
broadcastMethod · 0.45
unlockMethod · 0.45

Tested by

no test coverage detected