! * \brief Internal join function * \param auto_remove_ok Whether to allow join on an auto-remove thread */
| 252 | * \param auto_remove_ok Whether to allow join on an auto-remove thread |
| 253 | */ |
| 254 | void internal_join(bool auto_remove_ok) { |
| 255 | ReadLock guard(thread_mutex_); |
| 256 | // should be careful calling (or any function externally) this when in |
| 257 | // auto-remove mode |
| 258 | if (thread_.load() && thread_.load()->get_id() != std::thread::id()) { |
| 259 | std::thread::id someId; |
| 260 | if (!auto_remove_ok) { |
| 261 | CHECK_EQ(auto_remove_, false); |
| 262 | } |
| 263 | CHECK_NOTNULL(thread_.load()); |
| 264 | if (thread_.load()->joinable()) { |
| 265 | thread_.load()->join(); |
| 266 | } else { |
| 267 | LOG(WARNING) << "Thread " << name_ << " ( " |
| 268 | << thread_.load()->get_id() << " ) not joinable"; |
| 269 | } |
| 270 | } |
| 271 | } |
| 272 | |
| 273 | /*! |
| 274 | * \brief Thread bootstrapping and teardown wrapper |