Fix setting callback to use move operation in PrimitiveResource
authorcoderhyme <jhyo.kim@samsung.com>
Sat, 4 Jul 2015 02:35:48 +0000 (11:35 +0900)
committerUze Choi <uzchoi@samsung.com>
Mon, 6 Jul 2015 01:28:12 +0000 (01:28 +0000)
It was copying callback which is unneccesary overhead.

Change-Id: Iee927bb1192de7d8b8af71922f948e0428073ca2
Signed-off-by: coderhyme <jhyo.kim@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1515
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
service/resource-manipulation/modules/common/primitiveResource/include/internal/PrimitiveResourceImpl.h
service/resource-manipulation/modules/common/primitiveResource/src/PrimitiveResource.cpp
service/resource-manipulation/modules/common/primitiveResource/unittests/PrimitiveResourceTest.cpp

index d56d05d..b840639 100644 (file)
@@ -60,8 +60,8 @@ namespace OIC
                         const OC::QueryParamsMap&, OC::GetCallback);
 
                 invokeOC(m_baseResource, static_cast< GetFunc >(&BaseResource::get),
-                        OC::QueryParamsMap(),
-                        std::bind(callback, _1, std::bind(createResponseStatement, _2), _3));
+                        OC::QueryParamsMap(), std::bind(std::move(callback), _1,
+                                std::bind(createResponseStatement, _2), _3));
             }
 
             void requestSet(const ResourceAttributes& attrs, SetCallback callback) override
@@ -74,8 +74,8 @@ namespace OIC
 
                 invokeOC(m_baseResource, static_cast< PutFunc >(&BaseResource::put),
                         ResourceAttributesConverter::toOCRepresentation(attrs),
-                        OC::QueryParamsMap{ },
-                        std::bind(callback, _1, std::bind(createResponseStatement, _2), _3));
+                        OC::QueryParamsMap{ }, std::bind(std::move(callback), _1,
+                                std::bind(createResponseStatement, _2), _3));
             }
 
             void requestObserve(ObserveCallback callback) override
@@ -87,7 +87,7 @@ namespace OIC
 
                 invokeOC(m_baseResource, static_cast< ObserveFunc >(&BaseResource::observe),
                         OC::ObserveType::ObserveAll, OC::QueryParamsMap{ },
-                        bind(callback, _1, bind(createResponseStatement, _2), _3, _4));
+                        bind(std::move(callback), _1, bind(createResponseStatement, _2), _3, _4));
             }
 
             void cancelObserve() override
index 0f18065..b558fc9 100755 (executable)
@@ -44,8 +44,9 @@ namespace OIC
                     OCConnectivityType, OC::FindCallback);
 
             invokeOCFunc(static_cast<FindResource>(OC::OCPlatform::findResource),
-                    host, resourceURI, connectivityType, (OC::FindCallback) std::bind(callback,
-                           std::bind(&PrimitiveResource::create, std::placeholders::_1)));
+                    host, resourceURI, connectivityType, (OC::FindCallback)
+                        std::bind(std::move(callback),
+                                std::bind(&PrimitiveResource::create, std::placeholders::_1)));
         }
 
     }