From: Lukasz Wojciechowski Date: Wed, 11 Mar 2015 09:44:44 +0000 (+0100) Subject: Use functor object as main argument of callAndWait X-Git-Tag: security-manager_5.5_testing~133 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Ftest%2Fsecurity-tests.git;a=commitdiff_plain;h=544c17889148b36b2f22eec4cc40656a1d4a4046 Use functor object as main argument of callAndWait Previous solution was based on std::function, that causes problems because std::function template arguments needed to be explicitely defined. Functor simplifies usage of callAndWait. Change-Id: If4f8a640848e41042e6841e49354510c08db5357 --- diff --git a/src/common/timeout.h b/src/common/timeout.h index 7e985ab..98662e1 100644 --- a/src/common/timeout.h +++ b/src/common/timeout.h @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -34,9 +35,6 @@ namespace Timeout { template using Timeout = std::chrono::duration; -template -using Function = std::function; - typedef std::function CancelFunction; enum ExpectMode { @@ -62,16 +60,15 @@ std::ostream& operator<<(std::ostream& os, const std::future_status &status) return os; } -template -Ret callAndWait(const Timeout &timeout, +template + typename std::result_of::type + callAndWait(const Timeout &timeout, ExpectMode expect, CancelFunction cancelFunction, - Function function, - Args... args) { - RUNNER_ASSERT_MSG(function, - "not empty function must be passed to callAndWait"); + F&& function, + Args&&... args) { - std::future fut = std::async(std::launch::async, function, std::forward(args)...); + auto fut = std::async(std::launch::async, function, std::forward(args)...); std::future_status status = fut.wait_for(timeout); if (status == std::future_status::timeout && cancelFunction)