Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Unified Diff: Source/platform/ThreadSafeFunctional.h

Issue 1091333003: Add comments about threadSafeBind() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/wtf/Functional.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/ThreadSafeFunctional.h
diff --git a/Source/platform/ThreadSafeFunctional.h b/Source/platform/ThreadSafeFunctional.h
index 1b5b5dac85d625b4947fbf5d911a19e06dd3e201..9b8efdbad5274fcc71b49d9880d2149455a7ede7 100644
--- a/Source/platform/ThreadSafeFunctional.h
+++ b/Source/platform/ThreadSafeFunctional.h
@@ -10,6 +10,22 @@
namespace blink {
+// threadSafeBind() is bind() for cross-thread task posting.
+// threadSafeBind() applies CrossThreadCopier to the arguments.
+//
+// Example:
+// void func1(int, const String&);
+// f = threadSafeBind(func1, 42, str);
+// func1(42, str2) will be called when |f()| is executed,
+// where |str2| is a deep copy of |str| (created by str.isolatedCopy()).
+//
+// threadSafeBind(str) is similar to bind(str.isolatedCopy()), but the latter
+// is NOT thread-safe due to temporary objects (https://crbug.com/390851).
+//
+// Don't (if you pass the task across threads):
+// bind(func1, 42, str);
+// bind(func1, 42, str.isolatedCopy());
+
template<typename... FreeVariableTypes, typename FunctionType>
PassOwnPtr<Function<typename WTF::FunctionWrapper<FunctionType>::ResultType(FreeVariableTypes...)>> threadSafeBind(
FunctionType function)
« no previous file with comments | « no previous file | Source/wtf/Functional.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698