| 112 | } |
| 113 | |
| 114 | SCQueueSynchronizer::~SCQueueSynchronizer() noexcept { |
| 115 | #if defined(WIN32) && defined(__i386__) |
| 116 | if (SCQueueSynchronizer::is_into_atexit) { |
| 117 | mgb_log_warn("windows 32bit issue happened!!, resource recovery by OS!!"); |
| 118 | m_wait_finish_called = true; |
| 119 | //! need detach, if not, thread dtor will crash, OS will recovery thread |
| 120 | //! resource by call std::terminate. |
| 121 | m_worker_thread.detach(); |
| 122 | return; |
| 123 | } |
| 124 | #endif |
| 125 | if (!m_worker_started) |
| 126 | return; |
| 127 | if (!m_wait_finish_called) { |
| 128 | mgb_log_error("async queue not finished in destructor"); |
| 129 | mgb_trap(); |
| 130 | } |
| 131 | { |
| 132 | MGB_LOCK_GUARD(m_mtx_more_task); |
| 133 | m_should_exit = true; |
| 134 | m_cv_more_task.notify_all(); |
| 135 | } |
| 136 | m_worker_thread.join(); |
| 137 | } |
| 138 | |
| 139 | void SCQueueSynchronizer::start_worker(std::thread thread) { |
| 140 | mgb_assert(!m_worker_started); |