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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | base/sequenced_task_runner_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_SEQUENCED_TASK_RUNNER_H_ 5 #ifndef BASE_SEQUENCED_TASK_RUNNER_H_
6 #define BASE_SEQUENCED_TASK_RUNNER_H_ 6 #define BASE_SEQUENCED_TASK_RUNNER_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/base_export.h" 10 #include "base/base_export.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 147
148 protected: 148 protected:
149 ~SequencedTaskRunner() override {} 149 ~SequencedTaskRunner() override {}
150 150
151 private: 151 private:
152 bool DeleteOrReleaseSoonInternal(const tracked_objects::Location& from_here, 152 bool DeleteOrReleaseSoonInternal(const tracked_objects::Location& from_here,
153 void (*deleter)(const void*), 153 void (*deleter)(const void*),
154 const void* object); 154 const void* object);
155 }; 155 };
156 156
157 // Sample usage with std::unique_ptr :
158 // std::unique_ptr<Foo, base::OnTaskRunnerDeleter> ptr(
159 // new Foo, base::OnTaskRunnerDeleter(my_task_runner));
160 //
161 // TODO: RefCounted isn't yet supported per RefCountedTraits using a static
162 // deleter and thus not be bindable to a specific TaskRunner.
157 struct BASE_EXPORT OnTaskRunnerDeleter { 163 struct BASE_EXPORT OnTaskRunnerDeleter {
158 explicit OnTaskRunnerDeleter(scoped_refptr<SequencedTaskRunner> task_runner); 164 explicit OnTaskRunnerDeleter(scoped_refptr<SequencedTaskRunner> task_runner);
159 ~OnTaskRunnerDeleter(); 165 ~OnTaskRunnerDeleter();
160 166
161 OnTaskRunnerDeleter(OnTaskRunnerDeleter&&); 167 OnTaskRunnerDeleter(OnTaskRunnerDeleter&&);
162 OnTaskRunnerDeleter& operator=(OnTaskRunnerDeleter&&); 168 OnTaskRunnerDeleter& operator=(OnTaskRunnerDeleter&&);
163 169
170 // For compatibility with std:: deleters.
164 template <typename T> 171 template <typename T>
165 void operator()(const T* ptr) { 172 void operator()(const T* ptr) {
166 if (ptr) 173 if (ptr)
167 task_runner_->DeleteSoon(FROM_HERE, ptr); 174 task_runner_->DeleteSoon(FROM_HERE, ptr);
168 } 175 }
169 176
170 scoped_refptr<SequencedTaskRunner> task_runner_; 177 scoped_refptr<SequencedTaskRunner> task_runner_;
171 }; 178 };
172 179
173 } // namespace base 180 } // namespace base
174 181
175 #endif // BASE_SEQUENCED_TASK_RUNNER_H_ 182 #endif // BASE_SEQUENCED_TASK_RUNNER_H_
OLDNEW
« 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