Fix threads leaking if they're not joined. (bug 3460, r=dvander)
This commit is contained in:
parent
bded4f9142
commit
c28426a09f
@ -174,6 +174,11 @@ class Thread
|
|||||||
if (!initialized_)
|
if (!initialized_)
|
||||||
delete data;
|
delete data;
|
||||||
}
|
}
|
||||||
|
~Thread() {
|
||||||
|
if (!Succeeded())
|
||||||
|
return;
|
||||||
|
pthread_detach(thread_);
|
||||||
|
}
|
||||||
|
|
||||||
bool Succeeded() const {
|
bool Succeeded() const {
|
||||||
return initialized_;
|
return initialized_;
|
||||||
@ -183,6 +188,7 @@ class Thread
|
|||||||
if (!Succeeded())
|
if (!Succeeded())
|
||||||
return;
|
return;
|
||||||
pthread_join(thread_, NULL);
|
pthread_join(thread_, NULL);
|
||||||
|
initialized_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user