Commit ddc84d47 authored by Greg Thompson's avatar Greg Thompson Committed by Chromium LUCI CQ

Clarify documentation for self-destructing callbacks.

It's also okay to copy a RepeatingCallback onto the stack before running
it if running it may cause it to be deleted.

Bug: 1161804
Change-Id: I4ee5d81b5ab82505c4c3b02f872d3400d3d93ceb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2607886
Auto-Submit: Greg Thompson <grt@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Commit-Queue: Greg Thompson <grt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#840012}
parent 875f6b08
......@@ -372,9 +372,9 @@ void DoSomething(const base::RepeatingCallback<double(double)>& callback) {
If running a callback could result in its own destruction (e.g., if the callback
recipient deletes the object the callback is a member of), the callback should
be moved before it can be safely invoked. (Note that this is only an issue for
RepeatingCallbacks, because a OnceCallback always has to be moved for
execution.)
be moved or copied onto the stack before it can be safely invoked. (Note that
this is only an issue for RepeatingCallbacks, because a OnceCallback always has
to be moved for execution.)
```cpp
void Foo::RunCallback() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment