| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CrossThreadFunctional_h | 5 #ifndef CrossThreadFunctional_h |
| 6 #define CrossThreadFunctional_h | 6 #define CrossThreadFunctional_h |
| 7 | 7 |
| 8 #include <type_traits> |
| 8 #include "base/bind.h" | 9 #include "base/bind.h" |
| 9 #include "platform/CrossThreadCopier.h" | 10 #include "platform/CrossThreadCopier.h" |
| 10 #include "wtf/Functional.h" | 11 #include "wtf/Functional.h" |
| 11 #include <type_traits> | |
| 12 | 12 |
| 13 namespace blink { | 13 namespace blink { |
| 14 | 14 |
| 15 // crossThreadBind() is bind() for cross-thread task posting. | 15 // crossThreadBind() is bind() for cross-thread task posting. |
| 16 // crossThreadBind() applies CrossThreadCopier to the arguments. | 16 // crossThreadBind() applies CrossThreadCopier to the arguments. |
| 17 // | 17 // |
| 18 // Example: | 18 // Example: |
| 19 // void func1(int, const String&); | 19 // void func1(int, const String&); |
| 20 // f = crossThreadBind(func1, 42, str); | 20 // f = crossThreadBind(func1, 42, str); |
| 21 // func1(42, str2) will be called when |f()| is executed, | 21 // func1(42, str2) will be called when |f()| is executed, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 33 WTF::CrossThreadAffinity>> | 33 WTF::CrossThreadAffinity>> |
| 34 crossThreadBind(FunctionType function, Ps&&... parameters) { | 34 crossThreadBind(FunctionType function, Ps&&... parameters) { |
| 35 return WTF::bindInternal<WTF::CrossThreadAffinity>( | 35 return WTF::bindInternal<WTF::CrossThreadAffinity>( |
| 36 function, CrossThreadCopier<typename std::decay<Ps>::type>::copy( | 36 function, CrossThreadCopier<typename std::decay<Ps>::type>::copy( |
| 37 std::forward<Ps>(parameters))...); | 37 std::forward<Ps>(parameters))...); |
| 38 } | 38 } |
| 39 | 39 |
| 40 } // namespace blink | 40 } // namespace blink |
| 41 | 41 |
| 42 #endif // CrossThreadFunctional_h | 42 #endif // CrossThreadFunctional_h |
| OLD | NEW |