1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-10-27 05:23:39 -04:00

fix: Lock all mutexes on destruct

This commit is contained in:
Michael Carlberg 2016-06-21 04:26:42 +02:00
parent f48ab45834
commit ec2c27a44b
2 changed files with 14 additions and 19 deletions

View file

@ -92,6 +92,7 @@ namespace modules
protected: protected:
concurrency::SpinLock output_lock; concurrency::SpinLock output_lock;
concurrency::SpinLock broadcast_lock; concurrency::SpinLock broadcast_lock;
concurrency::SpinLock update_lock;
std::mutex sleep_lock; std::mutex sleep_lock;
std::condition_variable sleep_handler; std::condition_variable sleep_handler;
@ -119,13 +120,20 @@ namespace modules
this->stop(); this->stop();
std::lock_guard<concurrency::SpinLock> lck(this->broadcast_lock); std::lock_guard<concurrency::SpinLock> lck(this->broadcast_lock);
{
std::lock_guard<concurrency::SpinLock> lck(this->update_lock);
{
std::lock_guard<concurrency::SpinLock> lck(this->output_lock);
{
for (auto &&t : this->threads) { for (auto &&t : this->threads) {
if (t.joinable()) if (t.joinable())
t.join(); t.join();
else else
log_warning("["+ ConstCastModule(ModuleImpl).name() +"] Runner thread not joinable"); log_warning("["+ ConstCastModule(ModuleImpl).name() +"] Runner thread not joinable");
} }
}
}
}
log_trace(name()); log_trace(name());
} }
@ -256,8 +264,6 @@ namespace modules
protected: protected:
std::chrono::duration<double> interval = 1s; std::chrono::duration<double> interval = 1s;
concurrency::SpinLock update_lock;
void runner() void runner()
{ {
while (this->enabled()) { while (this->enabled()) {
@ -287,8 +293,6 @@ namespace modules
using Module<ModuleImpl>::Module; using Module<ModuleImpl>::Module;
protected: protected:
concurrency::SpinLock update_lock;
void runner() void runner()
{ {
// warmup // warmup

View file

@ -88,15 +88,6 @@ VolumeModule::VolumeModule(std::string name_) : EventModule(name_)
// }}} // }}}
} }
VolumeModule::~VolumeModule()
{
std::lock_guard<concurrency::SpinLock> lck(this->update_lock);
this->master_mixer.reset();
this->speaker_mixer.reset();
this->headphone_mixer.reset();
this->headphone_ctrl.reset();
}
bool VolumeModule::has_event() bool VolumeModule::has_event()
{ {
bool has_event = false; bool has_event = false;