MCPcopy Create free account
hub / github.com/a2flo/floor / finish

Method finish

src/threading/thread_base.cpp:86–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84}
85
86void thread_base::finish() {
87 if (thread_obj != nullptr) {
88 if ((get_thread_status() == THREAD_STATUS::FINISHED && !thread_obj->joinable()) ||
89 get_thread_status() == THREAD_STATUS::INIT) {
90 // already finished or uninitialized, nothing to do here
91 } else {
92 // signal thread to finish
93 set_thread_should_finish();
94
95 // wait a few ms
96 std::this_thread::sleep_for(100ms);
97
98 // this will block until the thread is finished
99 if (thread_obj->joinable()) {
100 thread_obj->join();
101 }
102 }
103
104 // finally: kill the thread object
105 thread_obj = nullptr;
106 }
107 // else: thread doesn't exist
108
109 set_thread_status(THREAD_STATUS::FINISHED);
110}
111
112void thread_base::set_thread_status(const thread_base::THREAD_STATUS status) {
113 thread_status = status;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected