void window::_move(window &this_one, window &other_one) { std::lock_guard<std::mutex> lock_other(other_one.m_lock); std::lock_guard<std::mutex> lock_me(this_one.m_lock); this_one.m_sdl_window = other_one.m_sdl_window; other_one.m_sdl_window = nullptr; }
void swap_data(protected_data_struct_deadlock& io_data) { if(&io_data == this) return; std::lock_guard<std::mutex> lock_this(m_mutex); std::this_thread::sleep_for(std::chrono::seconds(2)); std::lock_guard<std::mutex> lock_other(io_data.m_mutex); int tmp_data = io_data.m_data; io_data.m_data = m_data; m_data = tmp_data; }