From 093d1dd1982f3315249e83697cb1a6edcd05b866 Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Mon, 5 Dec 2016 20:50:52 +0000 Subject: [PATCH] Optimization - I *think* it's correct. --- src/async_connection.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/async_connection.cpp b/src/async_connection.cpp index 490dfc1..2451e1a 100644 --- a/src/async_connection.cpp +++ b/src/async_connection.cpp @@ -204,9 +204,10 @@ namespace redis { } void AsyncConnection::wakeup_event_thread() { - std::lock_guard lock(m_local_data->libev_mutex); - if (ev_async_pending(&m_local_data->watcher_wakeup) == false) + if (ev_async_pending(&m_local_data->watcher_wakeup) == false) { + std::lock_guard lock(m_local_data->libev_mutex); ev_async_send(m_libev_loop_thread.get(), &m_local_data->watcher_wakeup); + } } std::mutex& AsyncConnection::event_mutex() {