OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Specializations of RunnableAdapter<> for Windows specific calling | 5 // Specializations of RunnableAdapter<> for Windows specific calling |
6 // conventions. Please see base/bind_internal.h for more info. | 6 // conventions. Please see base/bind_internal.h for more info. |
7 | 7 |
8 #ifndef BASE_BIND_INTERNAL_WIN_H_ | 8 #ifndef BASE_BIND_INTERNAL_WIN_H_ |
9 #define BASE_BIND_INTERNAL_WIN_H_ | 9 #define BASE_BIND_INTERNAL_WIN_H_ |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 public: | 29 public: |
30 // MSVC 2013 doesn't support Type Alias of function types. | 30 // MSVC 2013 doesn't support Type Alias of function types. |
31 // Revisit this after we update it to newer version. | 31 // Revisit this after we update it to newer version. |
32 typedef R RunType(Args...); | 32 typedef R RunType(Args...); |
33 | 33 |
34 explicit RunnableAdapter(R(__stdcall *function)(Args...)) | 34 explicit RunnableAdapter(R(__stdcall *function)(Args...)) |
35 : function_(function) { | 35 : function_(function) { |
36 } | 36 } |
37 | 37 |
38 template <typename... RunArgs> | 38 template <typename... RunArgs> |
39 R Run(RunArgs&&... args) { | 39 R Run(RunArgs&&... args) const { |
40 return function_(std::forward<RunArgs>(args)...); | 40 return function_(std::forward<RunArgs>(args)...); |
41 } | 41 } |
42 | 42 |
43 private: | 43 private: |
44 R (__stdcall *function_)(Args...); | 44 R (__stdcall *function_)(Args...); |
45 }; | 45 }; |
46 | 46 |
47 // __fastcall Function. | 47 // __fastcall Function. |
48 template <typename R, typename... Args> | 48 template <typename R, typename... Args> |
49 class RunnableAdapter<R(__fastcall *)(Args...)> { | 49 class RunnableAdapter<R(__fastcall *)(Args...)> { |
50 public: | 50 public: |
51 // MSVC 2013 doesn't support Type Alias of function types. | 51 // MSVC 2013 doesn't support Type Alias of function types. |
52 // Revisit this after we update it to newer version. | 52 // Revisit this after we update it to newer version. |
53 typedef R RunType(Args...); | 53 typedef R RunType(Args...); |
54 | 54 |
55 explicit RunnableAdapter(R(__fastcall *function)(Args...)) | 55 explicit RunnableAdapter(R(__fastcall *function)(Args...)) |
56 : function_(function) { | 56 : function_(function) { |
57 } | 57 } |
58 | 58 |
59 template <typename... RunArgs> | 59 template <typename... RunArgs> |
60 R Run(RunArgs&&... args) { | 60 R Run(RunArgs&&... args) const { |
61 return function_(std::forward<RunArgs>(args)...); | 61 return function_(std::forward<RunArgs>(args)...); |
62 } | 62 } |
63 | 63 |
64 private: | 64 private: |
65 R (__fastcall *function_)(Args...); | 65 R (__fastcall *function_)(Args...); |
66 }; | 66 }; |
67 | 67 |
68 } // namespace internal | 68 } // namespace internal |
69 } // namespace base | 69 } // namespace base |
70 | 70 |
71 #endif // !defined(ARCH_CPU_X86_64) | 71 #endif // !defined(ARCH_CPU_X86_64) |
72 | 72 |
73 #endif // BASE_BIND_INTERNAL_WIN_H_ | 73 #endif // BASE_BIND_INTERNAL_WIN_H_ |
OLD | NEW |