OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef BASE_POST_TASK_AND_REPLY_WITH_RESULT_INTERNAL_H_ |
| 6 #define BASE_POST_TASK_AND_REPLY_WITH_RESULT_INTERNAL_H_ |
| 7 |
| 8 #include <utility> |
| 9 |
| 10 #include "base/callback.h" |
| 11 |
| 12 namespace base { |
| 13 |
| 14 namespace internal { |
| 15 |
| 16 // Adapts a function that produces a result via a return value to |
| 17 // one that returns via an output parameter. |
| 18 template <typename ReturnType> |
| 19 void ReturnAsParamAdapter(const Callback<ReturnType(void)>& func, |
| 20 ReturnType* result) { |
| 21 *result = func.Run(); |
| 22 } |
| 23 |
| 24 // Adapts a T* result to a callblack that expects a T. |
| 25 template <typename TaskReturnType, typename ReplyArgType> |
| 26 void ReplyAdapter(const Callback<void(ReplyArgType)>& callback, |
| 27 TaskReturnType* result) { |
| 28 callback.Run(std::move(*result)); |
| 29 } |
| 30 |
| 31 } // namespace internal |
| 32 |
| 33 } // namespace base |
| 34 |
| 35 #endif // BASE_POST_TASK_AND_REPLY_WITH_RESULT_INTERNAL_H_ |
OLD | NEW |