OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009-2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2009-2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 // | 78 // |
79 // Deep copies by threadSafeBind(): | 79 // Deep copies by threadSafeBind(): |
80 // |ptr|, |p1|, ..., |pn| are processed by threadSafeBind() and thus | 80 // |ptr|, |p1|, ..., |pn| are processed by threadSafeBind() and thus |
81 // CrossThreadCopier. | 81 // CrossThreadCopier. |
82 // You don't have to call manually e.g. isolatedCopy(). | 82 // You don't have to call manually e.g. isolatedCopy(). |
83 // To pass things that cannot be copied by CrossThreadCopier | 83 // To pass things that cannot be copied by CrossThreadCopier |
84 // (e.g. pointers), use AllowCrossThreadAccess() explicitly. | 84 // (e.g. pointers), use AllowCrossThreadAccess() explicitly. |
85 | 85 |
86 // RETTYPE, PS, and MPS are added as template parameters to circumvent MSVC 18.0
0.21005.1 (VS 2013) issues. | 86 // RETTYPE, PS, and MPS are added as template parameters to circumvent MSVC 18.0
0.21005.1 (VS 2013) issues. |
87 | 87 |
88 template<typename... P, typename... MP, | 88 template<typename FunctionType, typename... P, |
89 typename RETTYPE = std::unique_ptr<ExecutionContextTask>, size_t PS = sizeof
...(P), size_t MPS = sizeof...(MP)> | 89 typename RETTYPE = std::unique_ptr<ExecutionContextTask>, size_t PS = sizeof
...(P), size_t MPS = WTF::FunctionWrapper<FunctionType>::numberOfArguments> |
90 typename std::enable_if<PS + 1 == MPS, RETTYPE>::type createCrossThreadTask(void
(*function)(MP...), P&&... parameters) | 90 typename std::enable_if<PS + 1 == MPS, RETTYPE>::type createCrossThreadTask(Func
tionType function, P&&... parameters) |
91 { | 91 { |
92 return internal::CallClosureWithExecutionContextTask<WTF::CrossThreadAffinit
y>::create(threadSafeBind<ExecutionContext*>(function, std::forward<P>(parameter
s)...)); | 92 return internal::createCallClosureTask(threadSafeBind<ExecutionContext*>(fun
ction, std::forward<P>(parameters)...)); |
93 } | 93 } |
94 | 94 |
95 template<typename... P, typename... MP, | 95 template<typename FunctionType, typename... P, |
96 typename RETTYPE = std::unique_ptr<ExecutionContextTask>, size_t PS = sizeof
...(P), size_t MPS = sizeof...(MP)> | 96 typename RETTYPE = std::unique_ptr<ExecutionContextTask>, size_t PS = sizeof
...(P), size_t MPS = WTF::FunctionWrapper<FunctionType>::numberOfArguments> |
97 typename std::enable_if<PS == MPS, RETTYPE>::type createCrossThreadTask(void (*f
unction)(MP...), P&&... parameters) | 97 typename std::enable_if<PS == MPS, RETTYPE>::type createCrossThreadTask(Function
Type function, P&&... parameters) |
98 { | 98 { |
99 return internal::CallClosureTask<WTF::CrossThreadAffinity>::create(threadSaf
eBind(function, std::forward<P>(parameters)...)); | 99 return internal::createCallClosureTask(threadSafeBind(function, std::forward
<P>(parameters)...)); |
100 } | |
101 | |
102 template<typename C, typename... P, typename... MP, | |
103 typename RETTYPE = std::unique_ptr<ExecutionContextTask>, size_t PS = sizeof
...(P), size_t MPS = sizeof...(MP)> | |
104 typename std::enable_if<PS == MPS, RETTYPE>::type createCrossThreadTask(void (C:
:*function)(MP...), P&&... parameters) | |
105 { | |
106 return internal::CallClosureWithExecutionContextTask<WTF::CrossThreadAffinit
y>::create(threadSafeBind<ExecutionContext*>(function, std::forward<P>(parameter
s)...)); | |
107 } | |
108 | |
109 template<typename C, typename... P, typename... MP, | |
110 typename RETTYPE = std::unique_ptr<ExecutionContextTask>, size_t PS = sizeof
...(P), size_t MPS = sizeof...(MP)> | |
111 typename std::enable_if<PS == MPS + 1, RETTYPE>::type createCrossThreadTask(void
(C::*function)(MP...), P&&... parameters) | |
112 { | |
113 return internal::CallClosureTask<WTF::CrossThreadAffinity>::create(threadSaf
eBind(function, std::forward<P>(parameters)...)); | |
114 } | 100 } |
115 | 101 |
116 } // namespace blink | 102 } // namespace blink |
117 | 103 |
118 #endif // CrossThreadTask_h | 104 #endif // CrossThreadTask_h |
OLD | NEW |