diff --git a/src/pam/enter_device.cc b/src/pam/enter_device.cc index 66de0eb..0114d8d 100644 --- a/src/pam/enter_device.cc +++ b/src/pam/enter_device.cc @@ -21,7 +21,6 @@ EnterDevice::EnterDevice() strerror(-err)); } - raw_uinput_device.reset(uinput_dev_ptr); }; diff --git a/src/pam/main.hh b/src/pam/main.hh index b19d2ec..3d250fe 100644 --- a/src/pam/main.hh +++ b/src/pam/main.hh @@ -8,7 +8,12 @@ enum class ConfirmationType { Unset, Howdy, Pam }; enum class Workaround { Off, Input, Native }; // Exit status codes returned by the compare process -enum CompareError: int { NO_FACE_MODEL = 10, TIMEOUT_REACHED = 11, ABORT = 12, TOO_DARK = 13 }; +enum CompareError : int { + NO_FACE_MODEL = 10, + TIMEOUT_REACHED = 11, + ABORT = 12, + TOO_DARK = 13 +}; inline auto get_workaround(const std::string &workaround) -> Workaround { if (workaround == "input") { diff --git a/src/pam/optional_task.hh b/src/pam/optional_task.hh index ff4c551..36f9929 100644 --- a/src/pam/optional_task.hh +++ b/src/pam/optional_task.hh @@ -8,11 +8,11 @@ // A task executed only if activated. template class optional_task { - std::thread _thread; - std::packaged_task _task; - std::future _future; - bool _spawned; - bool _is_active; + std::thread thread; + std::packaged_task task; + std::future future; + bool spawned; + bool is_active; public: explicit optional_task(std::function fn); @@ -26,14 +26,14 @@ public: template optional_task::optional_task(std::function fn) - : _task(std::packaged_task(std::move(fn))), - _future(_task.get_future()), _is_active(false), _spawned(false) {} + : task(std::packaged_task(std::move(fn))), future(task.get_future()), + spawned(false), is_active(false) {} // Create a new thread and launch the task on it. template void optional_task::activate() { - _thread = std::thread(std::move(_task)); - _spawned = true; - _is_active = true; + thread = std::thread(std::move(task)); + spawned = true; + is_active = true; } // Wait for `dur` time and return a `future` status. @@ -41,15 +41,15 @@ template template auto optional_task::wait(std::chrono::duration dur) -> std::future_status { - return _future.wait_for(dur); + return future.wait_for(dur); } // Get the value. // WARNING: The function hould be run only if the task has successfully been // stopped. template auto optional_task::get() -> T { - assert(!_is_active && _spawned); - return _future.get(); + assert(!is_active && spawned); + return future.get(); } // Stop the thread: @@ -58,22 +58,22 @@ template auto optional_task::get() -> T { // WARNING: This function should be used with extreme caution when `force` is // set to `true`. template void optional_task::stop(bool force) { - if (!(_is_active && _thread.joinable()) && _spawned) { - _is_active = false; + if (!(is_active && thread.joinable()) && spawned) { + is_active = false; return; } // We use pthread to cancel the thread if (force) { - auto native_hd = _thread.native_handle(); + auto native_hd = thread.native_handle(); pthread_cancel(native_hd); } - _thread.join(); - _is_active = false; + thread.join(); + is_active = false; } template optional_task::~optional_task() { - if (_is_active && _spawned) { + if (is_active && spawned) { stop(false); } }