diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2016-09-14 20:22:34 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2016-09-14 20:22:34 +0000 |
commit | dd232d028dd951491fa71efbccd158bbb0cea92f (patch) | |
tree | 5fb63d26b5cc3ee688c146adc34148b9c9edc24c /filedistribution | |
parent | 094e09afb81e4a6b2cbcc4f11ed3bf9dd8ef1a7a (diff) |
Close ComponentsDeleter properly.
Diffstat (limited to 'filedistribution')
-rw-r--r-- | filedistribution/src/vespa/filedistribution/common/componentsdeleter.cpp | 9 | ||||
-rw-r--r-- | filedistribution/src/vespa/filedistribution/common/componentsdeleter.h | 4 |
2 files changed, 8 insertions, 5 deletions
diff --git a/filedistribution/src/vespa/filedistribution/common/componentsdeleter.cpp b/filedistribution/src/vespa/filedistribution/common/componentsdeleter.cpp index c184f5e1ae7..0aa5eb6cc80 100644 --- a/filedistribution/src/vespa/filedistribution/common/componentsdeleter.cpp +++ b/filedistribution/src/vespa/filedistribution/common/componentsdeleter.cpp @@ -60,15 +60,18 @@ ComponentsDeleter::waitForAllComponentsDeleted() void ComponentsDeleter::close() { - LockGuard guard(_trackedComponentsMutex); - _closed = true; + { + LockGuard guard(_trackedComponentsMutex); + _closed = true; + } + _deleteRequests.push([]() { LOG(debug, "I am the last one, hurry up and shutdown"); }); } bool ComponentsDeleter::allComponentsDeleted() { LockGuard guard(_trackedComponentsMutex); - return _trackedComponents.empty() && _deleteRequests.empty(); + return _closed && _trackedComponents.empty() && _deleteRequests.empty(); } void diff --git a/filedistribution/src/vespa/filedistribution/common/componentsdeleter.h b/filedistribution/src/vespa/filedistribution/common/componentsdeleter.h index 055f5fab242..de92f041da7 100644 --- a/filedistribution/src/vespa/filedistribution/common/componentsdeleter.h +++ b/filedistribution/src/vespa/filedistribution/common/componentsdeleter.h @@ -39,7 +39,7 @@ class ComponentsDeleter { template <class T> void requestDelete(T* component) { - _deleteRequests.push([&, component]() { deleteComponent<T>(component); }); + _deleteRequests.push([this, component]() { deleteComponent<T>(component); }); } void waitForAllComponentsDeleted(); @@ -65,7 +65,7 @@ class ComponentsDeleter { } _trackedComponents[t] = typeid(t).name(); - return std::shared_ptr<T>(t, [&](T * p) { requestDelete<T>(p); }); + return std::shared_ptr<T>(t, [this](T * p) { requestDelete<T>(p); }); } }; } |