Simplify reference counting implementation of PendingTaskSafetyFlag.

On a 32bit system, this reduces the allocation size of the flag
down from 12 bytes to 8, and removes the need for a vtable (the extra
4 bytes are the vtable pointer).

The downside is that this change makes the binary layout of the
flag, less compatible with RefCountedObject<> based reference counting
objects and thus we don't immediately get the benefits of identical
COMDAT folding and subsequently there's a slight binary size increase.
With wider use, the binary size benefits will come.

Bug: none
Change-Id: I04129771790a3258d6accaf0ab1258b7a798a55e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/215681
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33793}
This commit is contained in:
Tommi
2021-04-20 16:58:01 +02:00
committed by Commit Bot
parent e313c07020
commit 86ee89f73e
19 changed files with 105 additions and 49 deletions

View File

@ -106,8 +106,6 @@ OpenSLEngineManager::OpenSLEngineManager() {
thread_checker_.Detach();
}
OpenSLEngineManager::~OpenSLEngineManager() = default;
SLObjectItf OpenSLEngineManager::GetOpenSLEngine() {
RTC_LOG(INFO) << "GetOpenSLEngine";
RTC_DCHECK(thread_checker_.IsCurrent());

View File

@ -68,10 +68,11 @@ typedef ScopedSLObject<SLObjectItf, const SLObjectItf_*> ScopedSLObjectItf;
// Subsequent calls returns the already created engine.
// Note: This class must be used single threaded and this is enforced by a
// thread checker.
class OpenSLEngineManager : public rtc::RefCountedBase {
class OpenSLEngineManager
: public rtc::RefCountedNonVirtual<OpenSLEngineManager> {
public:
OpenSLEngineManager();
~OpenSLEngineManager() override;
~OpenSLEngineManager() = default;
SLObjectItf GetOpenSLEngine();
private:

View File

@ -20,10 +20,11 @@
namespace webrtc {
namespace jni {
class AddIceCandidateObserverJni final : public rtc::RefCountedBase {
class AddIceCandidateObserverJni final
: public rtc::RefCountedNonVirtual<AddIceCandidateObserverJni> {
public:
AddIceCandidateObserverJni(JNIEnv* env, const JavaRef<jobject>& j_observer);
~AddIceCandidateObserverJni() override = default;
~AddIceCandidateObserverJni() = default;
void OnComplete(RTCError error);