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

Method restart

dlib/threads/threaded_object_extension.cpp:130–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

128// ----------------------------------------------------------------------------------------
129
130 void threaded_object::
131 restart (
132 )
133 {
134 auto_mutex M(m_);
135
136 DLIB_ASSERT(id1 != get_thread_id() || id_valid == false,
137 "\tvoid threaded_object::restart()"
138 << "\n\tYou can NOT call this function from the thread that executes threaded_object::thread"
139 << "\n\tthis: " << this
140 );
141
142 if (is_alive_ == false)
143 {
144 if (create_new_thread<threaded_object,&threaded_object::thread_helper>(*this) == false)
145 {
146 is_running_ = false;
147 throw thread_error();
148 }
149 should_respawn_ = false;
150 }
151 else
152 {
153 should_respawn_ = true;
154 }
155 is_alive_ = true;
156 is_running_ = true;
157 should_stop_ = false;
158 s.broadcast();
159 }
160
161// ----------------------------------------------------------------------------------------
162

Callers

nothing calls this directly

Calls 3

thread_errorClass · 0.85
get_thread_idFunction · 0.70
broadcastMethod · 0.45

Tested by

no test coverage detected