OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 // Specializations of RunnableAdapter<> for Windows specific calling | |
6 // conventions. Please see base/bind_internal.h for more info. | |
7 | |
8 #ifndef BASE_BIND_INTERNAL_WIN_H_ | |
9 #define BASE_BIND_INTERNAL_WIN_H_ | |
10 | |
11 #include <utility> | |
12 | |
13 #include "build/build_config.h" | |
14 | |
15 // In the x64 architecture in Windows, __fastcall, __stdcall, etc, are all | |
16 // the same as __cdecl which would turn the following specializations into | |
17 // multiple definitions. | |
18 #if !defined(ARCH_CPU_X86_64) | |
19 | |
20 namespace base { | |
21 namespace internal { | |
22 | |
23 template <typename Functor> | |
24 class RunnableAdapter; | |
25 | |
26 // __stdcall Function. | |
27 template <typename R, typename... Args> | |
28 class RunnableAdapter<R(__stdcall *)(Args...)> { | |
29 public: | |
30 // MSVC 2013 doesn't support Type Alias of function types. | |
31 // Revisit this after we update it to newer version. | |
32 typedef R RunType(Args...); | |
33 | |
34 explicit RunnableAdapter(R(__stdcall *function)(Args...)) | |
35 : function_(function) { | |
36 } | |
37 | |
38 template <typename... RunArgs> | |
39 R Run(RunArgs&&... args) const { | |
40 return function_(std::forward<RunArgs>(args)...); | |
41 } | |
42 | |
43 private: | |
44 R (__stdcall *function_)(Args...); | |
45 }; | |
46 | |
47 // __fastcall Function. | |
48 template <typename R, typename... Args> | |
49 class RunnableAdapter<R(__fastcall *)(Args...)> { | |
50 public: | |
51 // MSVC 2013 doesn't support Type Alias of function types. | |
52 // Revisit this after we update it to newer version. | |
53 typedef R RunType(Args...); | |
54 | |
55 explicit RunnableAdapter(R(__fastcall *function)(Args...)) | |
56 : function_(function) { | |
57 } | |
58 | |
59 template <typename... RunArgs> | |
60 R Run(RunArgs&&... args) const { | |
61 return function_(std::forward<RunArgs>(args)...); | |
62 } | |
63 | |
64 private: | |
65 R (__fastcall *function_)(Args...); | |
66 }; | |
67 | |
68 } // namespace internal | |
69 } // namespace base | |
70 | |
71 #endif // !defined(ARCH_CPU_X86_64) | |
72 | |
73 #endif // BASE_BIND_INTERNAL_WIN_H_ | |
OLD | NEW |