Introduce RTC_NO_UNIQUE_ADDRESS.

This macro introduces the possibility to suggest the compiler that a
data member doesn't need an address different from other non static
data members.

The usage of a macro is to maintain portability since at the moment
the attribute [[no_unique_address]] is only supported by clang
with at least -std=c++11 but it should be supported by all the
compilers starting from C++20.

Bug: webrtc:11495
Change-Id: I9f12b67b4422a2749649eaa6b004a67d5fd572d8
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/173331
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32246}
This commit is contained in:
Mirko Bonadei
2020-09-30 10:04:20 +02:00
committed by Commit Bot
parent 1e4d4fdf88
commit f5e261aaf6
52 changed files with 138 additions and 42 deletions

View File

@ -110,6 +110,7 @@ rtc_library("video_coding") {
"../../api/video:video_bitrate_allocation",
"../../api/video:video_bitrate_allocator_factory",
"../../rtc_base:deprecation",
"../../rtc_base/system:no_unique_address",
"../../rtc_base/task_utils:to_queued_task",
"../../system_wrappers:field_trial",
"../../system_wrappers:metrics",
@ -353,6 +354,7 @@ rtc_library("video_coding_utility") {
"../../rtc_base/synchronization:sequence_checker",
"../../rtc_base/system:arch",
"../../rtc_base/system:file_wrapper",
"../../rtc_base/system:no_unique_address",
"../../rtc_base/task_utils:repeating_task",
"../../rtc_base/task_utils:to_queued_task",
"../../system_wrappers:field_trial",
@ -701,6 +703,7 @@ if (rtc_include_tests) {
"../../rtc_base:rtc_task_queue",
"../../rtc_base/synchronization:mutex",
"../../rtc_base/synchronization:sequence_checker",
"../../rtc_base/system:no_unique_address",
"../../rtc_base/task_utils:to_queued_task",
"../../test:test_support",
"../../test:video_test_common",

View File

@ -37,6 +37,7 @@
#include "rtc_base/checks.h"
#include "rtc_base/constructor_magic.h"
#include "rtc_base/synchronization/sequence_checker.h"
#include "rtc_base/system/no_unique_address.h"
#include "rtc_base/thread_annotations.h"
#include "rtc_base/thread_checker.h"
#include "test/testsupport/frame_reader.h"
@ -249,7 +250,7 @@ class VideoProcessor {
int64_t post_encode_time_ns_ RTC_GUARDED_BY(sequence_checker_);
// This class must be operated on a TaskQueue.
SequenceChecker sequence_checker_;
RTC_NO_UNIQUE_ADDRESS SequenceChecker sequence_checker_;
RTC_DISALLOW_COPY_AND_ASSIGN(VideoProcessor);
};

View File

@ -28,6 +28,7 @@
#include "rtc_base/numerics/sequence_number_util.h"
#include "rtc_base/synchronization/mutex.h"
#include "rtc_base/synchronization/sequence_checker.h"
#include "rtc_base/system/no_unique_address.h"
#include "rtc_base/task_queue.h"
#include "rtc_base/task_utils/repeating_task.h"
#include "rtc_base/thread_annotations.h"
@ -159,8 +160,8 @@ class FrameBuffer {
EncodedFrame* CombineAndDeleteFrames(
const std::vector<EncodedFrame*>& frames) const;
SequenceChecker construction_checker_;
SequenceChecker callback_checker_;
RTC_NO_UNIQUE_ADDRESS SequenceChecker construction_checker_;
RTC_NO_UNIQUE_ADDRESS SequenceChecker callback_checker_;
// Stores only undecoded frames.
FrameMap frames_ RTC_GUARDED_BY(mutex_);

View File

@ -19,6 +19,7 @@
#include "api/array_view.h"
#include "modules/include/module_common_types.h"
#include "rtc_base/synchronization/sequence_checker.h"
#include "rtc_base/system/no_unique_address.h"
namespace webrtc {
@ -102,7 +103,7 @@ class LossNotificationController {
// (Naturally, later frames must also be assemblable to be decodable.)
std::set<int64_t> decodable_frame_ids_ RTC_GUARDED_BY(sequence_checker_);
SequenceChecker sequence_checker_;
RTC_NO_UNIQUE_ADDRESS SequenceChecker sequence_checker_;
};
} // namespace webrtc

View File

@ -24,6 +24,7 @@
#include "rtc_base/ref_count.h"
#include "rtc_base/ref_counted_object.h"
#include "rtc_base/synchronization/sequence_checker.h"
#include "rtc_base/system/no_unique_address.h"
#include "rtc_base/task_queue.h"
namespace webrtc {
@ -82,7 +83,7 @@ class QualityScaler {
std::unique_ptr<CheckQpTask> pending_qp_task_ RTC_GUARDED_BY(&task_checker_);
QualityScalerQpUsageHandlerInterface* const handler_
RTC_GUARDED_BY(&task_checker_);
SequenceChecker task_checker_;
RTC_NO_UNIQUE_ADDRESS SequenceChecker task_checker_;
VideoEncoder::QpThresholds thresholds_ RTC_GUARDED_BY(&task_checker_);
const int64_t sampling_period_ms_;