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

Unified Diff: base/sequenced_task_runner.h

Issue 2921343002: Improve documentation and tests for base::OnTaskRunnerDeleter. (Closed)
Patch Set: rm unused include Created 3 years, 6 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 | base/sequenced_task_runner_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/sequenced_task_runner.h
diff --git a/base/sequenced_task_runner.h b/base/sequenced_task_runner.h
index 585a338d11634dcb7e708a024508f68dc02512bd..e42ba7fe312a84ad07a701e46758f13e9b303991 100644
--- a/base/sequenced_task_runner.h
+++ b/base/sequenced_task_runner.h
@@ -154,6 +154,12 @@ class BASE_EXPORT SequencedTaskRunner : public TaskRunner {
const void* object);
};
+// Sample usage with std::unique_ptr :
+// std::unique_ptr<Foo, base::OnTaskRunnerDeleter> ptr(
+// new Foo, base::OnTaskRunnerDeleter(my_task_runner));
+//
+// TODO: RefCounted isn't yet supported per RefCountedTraits using a static
+// deleter and thus not be bindable to a specific TaskRunner.
struct BASE_EXPORT OnTaskRunnerDeleter {
explicit OnTaskRunnerDeleter(scoped_refptr<SequencedTaskRunner> task_runner);
~OnTaskRunnerDeleter();
@@ -161,6 +167,7 @@ struct BASE_EXPORT OnTaskRunnerDeleter {
OnTaskRunnerDeleter(OnTaskRunnerDeleter&&);
OnTaskRunnerDeleter& operator=(OnTaskRunnerDeleter&&);
+ // For compatibility with std:: deleters.
template <typename T>
void operator()(const T* ptr) {
if (ptr)
« no previous file with comments | « no previous file | base/sequenced_task_runner_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698