summaryrefslogtreecommitdiff
path: root/cpp/src/IceBox/ServiceManagerI.cpp
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2015-12-30 12:52:26 +0100
committerJose <jose@zeroc.com>2015-12-30 12:52:26 +0100
commitdda483a63217585bc22a3b3c5392efcc2117ec57 (patch)
tree2bad562df5f525c9112eee08146a3ccdaafe8c03 /cpp/src/IceBox/ServiceManagerI.cpp
parentRemove unnecessary usage of ICE_CLOSE_CALLBACK (diff)
downloadice-dda483a63217585bc22a3b3c5392efcc2117ec57.tar.bz2
ice-dda483a63217585bc22a3b3c5392efcc2117ec57.tar.xz
ice-dda483a63217585bc22a3b3c5392efcc2117ec57.zip
Fixes to C++11 lambdas and this capture
Diffstat (limited to 'cpp/src/IceBox/ServiceManagerI.cpp')
-rw-r--r--cpp/src/IceBox/ServiceManagerI.cpp34
1 files changed, 15 insertions, 19 deletions
diff --git a/cpp/src/IceBox/ServiceManagerI.cpp b/cpp/src/IceBox/ServiceManagerI.cpp
index bd8ba14f4d7..27f7eb5db94 100644
--- a/cpp/src/IceBox/ServiceManagerI.cpp
+++ b/cpp/src/IceBox/ServiceManagerI.cpp
@@ -300,11 +300,7 @@ IceBox::ServiceManagerI::addObserver(ICE_IN(ServiceObserverPrxPtr) observer, con
if(activeServices.size() > 0)
{
#ifdef ICE_CPP11_MAPPING
- observer->servicesStarted_async(activeServices, nullptr,
- [this, observer](exception_ptr ex)
- {
- this->observerCompleted(observer, ex);
- });
+ observer->servicesStarted_async(activeServices, nullptr, makeObserverCompletedCallback(observer));
#else
observer->begin_servicesStarted(activeServices, _observerCompletedCB);
#endif
@@ -914,6 +910,18 @@ IceBox::ServiceManagerI::stopAll()
#ifdef ICE_CPP11_MAPPING
+function<void (exception_ptr)>
+IceBox::ServiceManagerI::makeObserverCompletedCallback(const shared_ptr<ServiceObserverPrx>& observer)
+{
+ return [self = weak_from_this(), observer](exception_ptr ex)
+ {
+ auto s = self.lock();
+ if(s)
+ {
+ s->observerCompleted(observer, ex);
+ }
+ };
+}
void
IceBox::ServiceManagerI::servicesStarted(const vector<string>& services, const set<shared_ptr<ServiceObserverPrx>>& observers)
{
@@ -921,13 +929,7 @@ IceBox::ServiceManagerI::servicesStarted(const vector<string>& services, const s
{
for(auto p : observers)
{
- p->servicesStarted_async(
- services,
- nullptr,
- [this, p](exception_ptr ex)
- {
- this->observerCompleted(p, ex);
- });
+ p->servicesStarted_async(services, nullptr, makeObserverCompletedCallback(p));
}
}
}
@@ -939,13 +941,7 @@ IceBox::ServiceManagerI::servicesStopped(const vector<string>& services, const s
{
for(auto p : observers)
{
- p->servicesStopped_async(
- services,
- nullptr,
- [this, p](exception_ptr ex)
- {
- this->observerCompleted(p, ex);
- });
+ p->servicesStopped_async(services, nullptr, makeObserverCompletedCallback(p));
}
}
}