summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface/evdev
diff options
context:
space:
mode:
authorMarkus Wick <degasus@users.noreply.github.com>2016-12-25 20:55:50 +0100
committerGitHub <noreply@github.com>2016-12-25 20:55:50 +0100
commit190c6218ab3785db75a3a10bf1b4c2fd7b367ceb (patch)
tree127558219e729d7d0139e2381c1be9b04ddaf7d2 /Source/Core/InputCommon/ControllerInterface/evdev
parent33559035856085a2a7d2aa490a0446d8f7044135 (diff)
parentf575902cf31ead3238d43ac475a5d3a33f83ce1f (diff)
Merge pull request #4493 from Tilka/evdev
Fix evdev threading
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/evdev')
-rw-r--r--Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp
index bee0c44a02..58f92f29a4 100644
--- a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp
@@ -116,32 +116,33 @@ static void HotplugThreadFunc()
static void StartHotplugThread()
{
- if (s_hotplug_thread_running.IsSet())
+ // Mark the thread as running.
+ if (!s_hotplug_thread_running.TestAndSet())
+ // It was already running.
return;
s_wakeup_eventfd = eventfd(0, 0);
_assert_msg_(PAD, s_wakeup_eventfd != -1, "Couldn't create eventfd.");
- s_hotplug_thread_running.Set(true);
s_hotplug_thread = std::thread(HotplugThreadFunc);
}
static void StopHotplugThread()
{
- if (s_hotplug_thread_running.TestAndClear())
+ // Tell the hotplug thread to stop.
+ if (!s_hotplug_thread_running.TestAndClear())
+ // It wasn't running, we're done.
+ return;
+ // Write something to efd so that select() stops blocking.
+ uint64_t value = 1;
+ if (write(s_wakeup_eventfd, &value, sizeof(uint64_t)) < 0)
{
- // Write something to efd so that select() stops blocking.
- uint64_t value = 1;
- if (write(s_wakeup_eventfd, &value, sizeof(uint64_t)) < 0)
- {
- }
- s_hotplug_thread.join();
}
+ s_hotplug_thread.join();
}
void Init()
{
s_devnode_name_map.clear();
- PopulateDevices();
StartHotplugThread();
}