Simplify mutex locking in WindowCount module
- Acquire lock once at start of update() and hold for entire function - Remove redundant lock from queryActiveWorkspace() since it's only called from update() This addresses code review feedback and makes the locking strategy clearer Co-authored-by: Alexays <13947260+Alexays@users.noreply.github.com>
This commit is contained in:
@ -37,6 +37,8 @@ WindowCount::~WindowCount() {
|
||||
}
|
||||
|
||||
auto WindowCount::update() -> void {
|
||||
std::lock_guard<std::mutex> lg(mutex_);
|
||||
|
||||
queryActiveWorkspace();
|
||||
|
||||
std::string format = config_["format"].asString();
|
||||
@ -44,8 +46,6 @@ auto WindowCount::update() -> void {
|
||||
std::string formatWindowed = config_["format-windowed"].asString();
|
||||
std::string formatFullscreen = config_["format-fullscreen"].asString();
|
||||
|
||||
std::lock_guard<std::mutex> lg(mutex_);
|
||||
|
||||
setClass("empty", workspace_.windows == 0);
|
||||
setClass("fullscreen", workspace_.hasfullscreen);
|
||||
|
||||
@ -118,8 +118,6 @@ auto WindowCount::Workspace::parse(const Json::Value& value) -> WindowCount::Wor
|
||||
}
|
||||
|
||||
void WindowCount::queryActiveWorkspace() {
|
||||
std::lock_guard<std::mutex> lg(mutex_);
|
||||
|
||||
if (separateOutputs_) {
|
||||
workspace_ = getActiveWorkspace(this->bar_.output->name);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user