| 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 17 matching lines...) Expand all Loading... |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef CrossThreadTask_h | 31 #ifndef CrossThreadTask_h |
| 32 #define CrossThreadTask_h | 32 #define CrossThreadTask_h |
| 33 | 33 |
| 34 #include "core/dom/ExecutionContext.h" | 34 #include "core/dom/ExecutionContext.h" |
| 35 #include "core/dom/ExecutionContextTask.h" | 35 #include "core/dom/ExecutionContextTask.h" |
| 36 #include "platform/ThreadSafeFunctional.h" | 36 #include "platform/ThreadSafeFunctional.h" |
| 37 #include "wtf/PassOwnPtr.h" | 37 #include "wtf/PassOwnPtr.h" |
| 38 #include "wtf/PassRefPtr.h" | |
| 39 #include <type_traits> | 38 #include <type_traits> |
| 40 | 39 |
| 41 namespace blink { | 40 namespace blink { |
| 42 | 41 |
| 43 // createCrossThreadTask(...) is similar to but safer than | 42 // createCrossThreadTask(...) is similar to but safer than |
| 44 // CallClosureTask::create(bind(...)) for cross-thread task posting. | 43 // CallClosureTask::create(bind(...)) for cross-thread task posting. |
| 45 // postTask(CallClosureTask::create(bind(...))) is not thread-safe | 44 // postTask(CallClosureTask::create(bind(...))) is not thread-safe |
| 46 // due to temporary objects, see http://crbug.com/390851 for details. | 45 // due to temporary objects, see http://crbug.com/390851 for details. |
| 47 // | 46 // |
| 48 // Example: | 47 // Example: |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 template<typename C, typename... P, typename... MP, | 139 template<typename C, typename... P, typename... MP, |
| 141 typename RETTYPE = PassOwnPtr<ExecutionContextTask>, size_t PS = sizeof...(P
), size_t MPS = sizeof...(MP)> | 140 typename RETTYPE = PassOwnPtr<ExecutionContextTask>, size_t PS = sizeof...(P
), size_t MPS = sizeof...(MP)> |
| 142 typename std::enable_if<PS == MPS + 1, RETTYPE>::type createCrossThreadTask(void
(C::*function)(MP...), const P&... parameters) | 141 typename std::enable_if<PS == MPS + 1, RETTYPE>::type createCrossThreadTask(void
(C::*function)(MP...), const P&... parameters) |
| 143 { | 142 { |
| 144 return internal::CallClosureTask<WTF::CrossThreadAffinity>::create(threadSaf
eBind(function, parameters...)); | 143 return internal::CallClosureTask<WTF::CrossThreadAffinity>::create(threadSaf
eBind(function, parameters...)); |
| 145 } | 144 } |
| 146 | 145 |
| 147 } // namespace blink | 146 } // namespace blink |
| 148 | 147 |
| 149 #endif // CrossThreadTask_h | 148 #endif // CrossThreadTask_h |
| OLD | NEW |