Ban std::shared_ptr in style guide

As a sideswipe, note that sigslot is deprecated.

Bug: none
Change-Id: I8dab9035377fa4155c5f7a99a1f6a4345fcb1e17
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/215660
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Tommi <tommi@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33774}
This commit is contained in:
Harald Alvestrand
2021-04-19 13:28:21 +00:00
committed by Commit Bot
parent 25e735239c
commit f703ed1e24

View File

@ -124,42 +124,28 @@ See [the source](api/array_view.h) for more detailed docs.
### sigslot ### sigslot
sigslot is a lightweight library that adds a signal/slot language SIGSLOT IS DEPRECATED.
construct to C++, making it easy to implement the observer pattern
with minimal boilerplate code.
When adding a signal to a pure interface, **prefer to add a pure Prefer webrtc::CallbackList, and manage thread safety yourself.
virtual method that returns a reference to a signal**:
``` ### Smart pointers
sigslot::signal<int>& SignalFoo() = 0;
```
As opposed to making it a public member variable, as a lot of legacy The following smart pointer types are recommended:
code does:
``` * std::unique_ptr for all singly-owned objects
sigslot::signal<int> SignalFoo; * rtc::scoped_refptr for all objects with shared ownership
```
The virtual method approach has the advantage that it keeps the Use of std::shared_ptr is *not permitted*. It is
interface stateless, and gives the subclass more flexibility in how it [banned](https://chromium-cpp.appspot.com/#library-blocklist) in the Chromium
implements the signal. It may: style guide (overriding the Google style guide), and offers no compelling
advantage over rtc::scoped_refptr (which is cloned from the corresponding
Chromium type).
* Have its own signal as a member variable. In most cases, one will want to explicitly control lifetimes, and therefore
* Use a `sigslot::repeater`, to repeat a signal of another object: use std::unique_ptr, but in some cases, for instance where references have
to exist both from the API users and internally, with no way to
``` invalidate pointers held by the API user, rtc::scoped_refptr can be
sigslot::repeater<int> foo_; appropriate.
/* ... */
foo_.repeat(bar_.SignalFoo());
```
* Just return another object's signal directly, if the other object's
lifetime is the same as its own.
```
sigslot::signal<int>& SignalFoo() { return bar_.SignalFoo(); }
```
### std::bind ### std::bind