fix(eventloop): Acquire lock guard

This commit is contained in:
Michael Carlberg 2016-12-14 19:04:33 +01:00
parent e11798253a
commit 4c36d65cbe
3 changed files with 10 additions and 10 deletions

View File

@ -121,16 +121,16 @@ class eventloop : public signal_receiver<SIGN_PRIORITY_EVENTLOOP, process_quit,
*/ */
chrono::milliseconds m_swallow_input{30ms}; chrono::milliseconds m_swallow_input{30ms};
/**
* @brief Time of last handled input event
*/
chrono::time_point<chrono::system_clock, chrono::milliseconds> m_lastinput;
/** /**
* @brief Mutex used to guard input data * @brief Mutex used to guard input data
*/ */
std::mutex m_inputlock; std::mutex m_inputlock;
/**
* @brief Time of last handled input event
*/
chrono::time_point<chrono::system_clock, decltype(m_swallow_input)> m_lastinput;
/** /**
* @brief Input data * @brief Input data
*/ */

View File

@ -124,7 +124,6 @@ bool eventloop::enqueue(event&& evt) {
m_log.warn("Failed to enqueue event"); m_log.warn("Failed to enqueue event");
return false; return false;
} }
return true; return true;
} }
@ -132,7 +131,7 @@ bool eventloop::enqueue(event&& evt) {
* Enqueue input data * Enqueue input data
*/ */
bool eventloop::enqueue(string&& input_data) { bool eventloop::enqueue(string&& input_data) {
if (m_inputlock.try_lock()) { if (!m_inputlock.try_lock()) {
return false; return false;
} }
@ -146,7 +145,8 @@ bool eventloop::enqueue(string&& input_data) {
return false; return false;
} }
m_inputdata = forward<string>(input_data); m_inputdata = move(input_data);
return enqueue(make_input_evt()); return enqueue(make_input_evt());
} }

View File

@ -209,10 +209,10 @@ namespace modules {
m_log.info("%s: Sending workspace focus command to ipc handler", name()); m_log.info("%s: Sending workspace focus command to ipc handler", name());
conn.send_command("workspace number " + workspace_num); conn.send_command("workspace number " + workspace_num);
} }
} else if (cmd.compare(0, strlen(EVENT_SCROLL_DOWN), EVENT_SCROLL_DOWN) == 0) {
scrolldir = m_revscroll ? "next" : "prev";
} else if (cmd.compare(0, strlen(EVENT_SCROLL_UP), EVENT_SCROLL_UP) == 0) { } else if (cmd.compare(0, strlen(EVENT_SCROLL_UP), EVENT_SCROLL_UP) == 0) {
scrolldir = m_revscroll ? "prev" : "next"; scrolldir = m_revscroll ? "prev" : "next";
} else if (cmd.compare(0, strlen(EVENT_SCROLL_DOWN), EVENT_SCROLL_DOWN) == 0) {
scrolldir = m_revscroll ? "next" : "prev";
} else { } else {
return false; return false;
} }