mirror of
https://github.com/clangen/musikcube.git
synced 2025-01-30 06:32:36 +00:00
Fixed a deadlock on shutdown introduced in the previous commit.
This commit is contained in:
parent
144e5eeadc
commit
0e11128d0c
@ -98,6 +98,7 @@ Indexer::~Indexer() {
|
||||
this->exit = true;
|
||||
}
|
||||
|
||||
this->waitCondition.notify_all();
|
||||
this->thread->join();
|
||||
delete this->thread;
|
||||
this->thread = nullptr;
|
||||
@ -107,7 +108,7 @@ Indexer::~Indexer() {
|
||||
void Indexer::Synchronize(bool restart) {
|
||||
boost::mutex::scoped_lock lock(this->stateMutex);
|
||||
this->restart = restart;
|
||||
this->Notify();
|
||||
this->waitCondition.notify_all();
|
||||
}
|
||||
|
||||
void Indexer::AddPath(const std::string& path) {
|
||||
@ -407,12 +408,12 @@ void Indexer::ThreadLoop() {
|
||||
waitTimeout.sec += waitTime;
|
||||
|
||||
if (!this->Restarted()) {
|
||||
this->NotificationTimedWait(waitTimeout);
|
||||
this->Wait(waitTimeout);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!this->Restarted()) {
|
||||
this->NotificationWait(); /* zzz */
|
||||
this->Wait(); /* zzz */
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -689,20 +690,16 @@ bool Indexer::Exited() {
|
||||
return this->exit;
|
||||
}
|
||||
|
||||
void Indexer::NotificationWait() {
|
||||
void Indexer::Wait() {
|
||||
boost::mutex::scoped_lock lock(this->stateMutex);
|
||||
if (!this->exit) {
|
||||
this->waitCondition.wait(lock);
|
||||
}
|
||||
}
|
||||
|
||||
void Indexer::NotificationTimedWait(const boost::xtime &time) {
|
||||
void Indexer::Wait(const boost::xtime &time) {
|
||||
boost::mutex::scoped_lock lock(this->stateMutex);
|
||||
if (!this->exit) {
|
||||
this->waitCondition.timed_wait(lock, time);
|
||||
}
|
||||
}
|
||||
|
||||
void Indexer::Notify() {
|
||||
this->waitCondition.notify_all();
|
||||
}
|
@ -71,9 +71,8 @@ namespace musik { namespace core {
|
||||
void ThreadLoop();
|
||||
|
||||
bool Exited();
|
||||
void NotificationWait();
|
||||
void NotificationTimedWait(const boost::xtime &oTime);
|
||||
void Notify();
|
||||
void Wait();
|
||||
void Wait(const boost::xtime &oTime);
|
||||
|
||||
bool Restarted();
|
||||
|
||||
|
@ -47,8 +47,6 @@ namespace cursespp {
|
||||
virtual void SetWidth(size_t width);
|
||||
virtual int64 GetAttrs(size_t line);
|
||||
|
||||
void SetAttrs(int64 attrs);
|
||||
|
||||
private:
|
||||
std::string value;
|
||||
std::vector<std::string> lines;
|
||||
|
Loading…
x
Reference in New Issue
Block a user