From 2b85792b01fc077ae08075ef552f67f94b697930 Mon Sep 17 00:00:00 2001 From: Karl Wiberg Date: Fri, 23 Mar 2018 14:53:54 +0100 Subject: [PATCH] Move rw_lock_wrapper.h to rtc_base/synchronization/ This moves it from an API directory (system_wrappers/include/) to a non-API directory, which is exactly what we want for utilities like this. BUG=webrtc:8445 NOPRESUBMIT=true Change-Id: Ie2879aca5fc1667e4222499d2a8fc2bba9ae2425 Reviewed-on: https://webrtc-review.googlesource.com/21328 Commit-Queue: Karl Wiberg Reviewed-by: Danil Chapovalov Cr-Commit-Position: refs/heads/master@{#22587} --- call/BUILD.gn | 1 + call/call.cc | 2 +- modules/audio_coding/BUILD.gn | 1 + modules/audio_coding/test/APITest.h | 2 +- modules/audio_coding/test/RTPFile.cc | 2 +- modules/audio_coding/test/RTPFile.h | 2 +- modules/desktop_capture/BUILD.gn | 1 + .../desktop_capture/screen_capturer_helper.h | 2 +- modules/video_capture/BUILD.gn | 1 + modules/video_capture/device_info_impl.h | 2 +- rtc_base/synchronization/BUILD.gn | 38 +++++++++++++++++++ .../synchronization}/rw_lock_posix.cc | 2 +- .../synchronization}/rw_lock_posix.h | 12 +++--- .../synchronization}/rw_lock_win.cc | 2 +- .../synchronization}/rw_lock_win.h | 17 ++++----- .../synchronization/rw_lock_wrapper.cc | 6 +-- .../synchronization}/rw_lock_wrapper.h | 12 +++--- rtc_base/time/BUILD.gn | 2 +- rtc_base/time/timestamp_extrapolator.h | 2 +- system_wrappers/BUILD.gn | 7 +--- system_wrappers/include/clock.h | 2 +- system_wrappers/source/clock.cc | 2 +- 22 files changed, 79 insertions(+), 41 deletions(-) create mode 100644 rtc_base/synchronization/BUILD.gn rename {system_wrappers/source => rtc_base/synchronization}/rw_lock_posix.cc (95%) rename {system_wrappers/source => rtc_base/synchronization}/rw_lock_posix.h (80%) rename {system_wrappers/source => rtc_base/synchronization}/rw_lock_win.cc (98%) rename {system_wrappers/source => rtc_base/synchronization}/rw_lock_win.h (63%) rename system_wrappers/source/rw_lock.cc => rtc_base/synchronization/rw_lock_wrapper.cc (80%) rename {system_wrappers/include => rtc_base/synchronization}/rw_lock_wrapper.h (83%) diff --git a/call/BUILD.gn b/call/BUILD.gn index f43acd3e31..c615f9dd22 100644 --- a/call/BUILD.gn +++ b/call/BUILD.gn @@ -188,6 +188,7 @@ rtc_static_library("call") { "../rtc_base:rtc_task_queue", "../rtc_base:safe_minmax", "../rtc_base:sequenced_task_checker", + "../rtc_base/synchronization:rw_lock_wrapper", "../system_wrappers", "../system_wrappers:field_trial_api", "../system_wrappers:metrics_api", diff --git a/call/call.cc b/call/call.cc index d19fb4b2c9..72e7431924 100644 --- a/call/call.cc +++ b/call/call.cc @@ -54,13 +54,13 @@ #include "rtc_base/ptr_util.h" #include "rtc_base/rate_limiter.h" #include "rtc_base/sequenced_task_checker.h" +#include "rtc_base/synchronization/rw_lock_wrapper.h" #include "rtc_base/task_queue.h" #include "rtc_base/thread_annotations.h" #include "rtc_base/trace_event.h" #include "system_wrappers/include/clock.h" #include "system_wrappers/include/cpu_info.h" #include "system_wrappers/include/metrics.h" -#include "system_wrappers/include/rw_lock_wrapper.h" #include "video/call_stats.h" #include "video/send_delay_stats.h" #include "video/stats_counter.h" diff --git a/modules/audio_coding/BUILD.gn b/modules/audio_coding/BUILD.gn index 28ba7d36e4..ea696663a0 100644 --- a/modules/audio_coding/BUILD.gn +++ b/modules/audio_coding/BUILD.gn @@ -1378,6 +1378,7 @@ if (rtc_include_tests) { "../../api:optional", "../../api/audio_codecs:builtin_audio_decoder_factory", "../../rtc_base:rtc_base_approved", + "../../rtc_base/synchronization:rw_lock_wrapper", "../../system_wrappers", "../../test:fileutils", "../../test:test_support", diff --git a/modules/audio_coding/test/APITest.h b/modules/audio_coding/test/APITest.h index 652d7c401c..35182eef3c 100644 --- a/modules/audio_coding/test/APITest.h +++ b/modules/audio_coding/test/APITest.h @@ -18,8 +18,8 @@ #include "modules/audio_coding/test/Channel.h" #include "modules/audio_coding/test/PCMFile.h" #include "modules/audio_coding/test/utility.h" +#include "rtc_base/synchronization/rw_lock_wrapper.h" #include "system_wrappers/include/event_wrapper.h" -#include "system_wrappers/include/rw_lock_wrapper.h" namespace webrtc { diff --git a/modules/audio_coding/test/RTPFile.cc b/modules/audio_coding/test/RTPFile.cc index 38f304ea7c..6ea5354154 100644 --- a/modules/audio_coding/test/RTPFile.cc +++ b/modules/audio_coding/test/RTPFile.cc @@ -20,7 +20,7 @@ #endif #include "audio_coding_module.h" -#include "system_wrappers/include/rw_lock_wrapper.h" +#include "rtc_base/synchronization/rw_lock_wrapper.h" // TODO(tlegrand): Consider removing usage of gtest. #include "test/gtest.h" #include "typedefs.h" // NOLINT(build/include) diff --git a/modules/audio_coding/test/RTPFile.h b/modules/audio_coding/test/RTPFile.h index 34dae63b2a..d7e8c26606 100644 --- a/modules/audio_coding/test/RTPFile.h +++ b/modules/audio_coding/test/RTPFile.h @@ -16,7 +16,7 @@ #include "modules/audio_coding/include/audio_coding_module.h" #include "modules/include/module_common_types.h" -#include "system_wrappers/include/rw_lock_wrapper.h" +#include "rtc_base/synchronization/rw_lock_wrapper.h" #include "typedefs.h" // NOLINT(build/include) namespace webrtc { diff --git a/modules/desktop_capture/BUILD.gn b/modules/desktop_capture/BUILD.gn index aaf1f2939b..bd0834c54a 100644 --- a/modules/desktop_capture/BUILD.gn +++ b/modules/desktop_capture/BUILD.gn @@ -363,6 +363,7 @@ rtc_static_library("desktop_capture_generic") { "../../api:refcountedbase", "../../rtc_base:checks", "../../rtc_base:rtc_base", # TODO(kjellander): Cleanup in bugs.webrtc.org/3806. + "../../rtc_base/synchronization:rw_lock_wrapper", "../../system_wrappers", "../../system_wrappers:cpu_features_api", "../../system_wrappers:metrics_api", diff --git a/modules/desktop_capture/screen_capturer_helper.h b/modules/desktop_capture/screen_capturer_helper.h index d36be49b60..d8fc36837b 100644 --- a/modules/desktop_capture/screen_capturer_helper.h +++ b/modules/desktop_capture/screen_capturer_helper.h @@ -16,7 +16,7 @@ #include "modules/desktop_capture/desktop_geometry.h" #include "modules/desktop_capture/desktop_region.h" #include "rtc_base/constructormagic.h" -#include "system_wrappers/include/rw_lock_wrapper.h" +#include "rtc_base/synchronization/rw_lock_wrapper.h" namespace webrtc { diff --git a/modules/video_capture/BUILD.gn b/modules/video_capture/BUILD.gn index d0ee6f88fa..8d1859fca8 100644 --- a/modules/video_capture/BUILD.gn +++ b/modules/video_capture/BUILD.gn @@ -37,6 +37,7 @@ rtc_static_library("video_capture_module") { "../../media:rtc_media_base", "../../rtc_base:rtc_base_approved", "../../rtc_base:stringutils", + "../../rtc_base/synchronization:rw_lock_wrapper", "../../system_wrappers", "//third_party/libyuv", ] diff --git a/modules/video_capture/device_info_impl.h b/modules/video_capture/device_info_impl.h index 296adfbbab..7e23f043fd 100644 --- a/modules/video_capture/device_info_impl.h +++ b/modules/video_capture/device_info_impl.h @@ -14,7 +14,7 @@ #include #include "modules/video_capture/video_capture.h" -#include "system_wrappers/include/rw_lock_wrapper.h" +#include "rtc_base/synchronization/rw_lock_wrapper.h" namespace webrtc { diff --git a/rtc_base/synchronization/BUILD.gn b/rtc_base/synchronization/BUILD.gn new file mode 100644 index 0000000000..9d9ea6f775 --- /dev/null +++ b/rtc_base/synchronization/BUILD.gn @@ -0,0 +1,38 @@ +# Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. +# +# Use of this source code is governed by a BSD-style license +# that can be found in the LICENSE file in the root of the source +# tree. An additional intellectual property rights grant can be found +# in the file PATENTS. All contributing project authors may +# be found in the AUTHORS file in the root of the source tree. + +import("../../webrtc.gni") +if (is_android) { + import("//build/config/android/config.gni") + import("//build/config/android/rules.gni") +} + +rtc_source_set("rw_lock_wrapper") { + public = [ + "rw_lock_wrapper.h", + ] + sources = [ + "rw_lock_wrapper.cc", + ] + deps = [ + "..:macromagic", + "../..:typedefs", + ] + if (is_win) { + sources += [ + "rw_lock_win.cc", + "rw_lock_win.h", + ] + deps += [ "..:logging" ] + } else { + sources += [ + "rw_lock_posix.cc", + "rw_lock_posix.h", + ] + } +} diff --git a/system_wrappers/source/rw_lock_posix.cc b/rtc_base/synchronization/rw_lock_posix.cc similarity index 95% rename from system_wrappers/source/rw_lock_posix.cc rename to rtc_base/synchronization/rw_lock_posix.cc index 412873c770..7e37dc924f 100644 --- a/system_wrappers/source/rw_lock_posix.cc +++ b/rtc_base/synchronization/rw_lock_posix.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "system_wrappers/source/rw_lock_posix.h" +#include "rtc_base/synchronization/rw_lock_posix.h" namespace webrtc { diff --git a/system_wrappers/source/rw_lock_posix.h b/rtc_base/synchronization/rw_lock_posix.h similarity index 80% rename from system_wrappers/source/rw_lock_posix.h rename to rtc_base/synchronization/rw_lock_posix.h index d15682b928..9a92bcd2b0 100644 --- a/system_wrappers/source/rw_lock_posix.h +++ b/rtc_base/synchronization/rw_lock_posix.h @@ -8,14 +8,14 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef SYSTEM_WRAPPERS_SOURCE_RW_LOCK_POSIX_H_ -#define SYSTEM_WRAPPERS_SOURCE_RW_LOCK_POSIX_H_ - -#include "system_wrappers/include/rw_lock_wrapper.h" -#include "typedefs.h" // NOLINT(build/include) +#ifndef RTC_BASE_SYNCHRONIZATION_RW_LOCK_POSIX_H_ +#define RTC_BASE_SYNCHRONIZATION_RW_LOCK_POSIX_H_ #include +#include "rtc_base/synchronization/rw_lock_wrapper.h" +#include "typedefs.h" // NOLINT(build/include) + namespace webrtc { class RWLockPosix : public RWLockWrapper { @@ -38,4 +38,4 @@ class RWLockPosix : public RWLockWrapper { } // namespace webrtc -#endif // SYSTEM_WRAPPERS_SOURCE_RW_LOCK_POSIX_H_ +#endif // RTC_BASE_SYNCHRONIZATION_RW_LOCK_POSIX_H_ diff --git a/system_wrappers/source/rw_lock_win.cc b/rtc_base/synchronization/rw_lock_win.cc similarity index 98% rename from system_wrappers/source/rw_lock_win.cc rename to rtc_base/synchronization/rw_lock_win.cc index 23df15a275..44cc0a75b3 100644 --- a/system_wrappers/source/rw_lock_win.cc +++ b/rtc_base/synchronization/rw_lock_win.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "system_wrappers/source/rw_lock_win.h" +#include "rtc_base/synchronization/rw_lock_win.h" #include "rtc_base/logging.h" diff --git a/system_wrappers/source/rw_lock_win.h b/rtc_base/synchronization/rw_lock_win.h similarity index 63% rename from system_wrappers/source/rw_lock_win.h rename to rtc_base/synchronization/rw_lock_win.h index 41537ba10b..52ad9bbe40 100644 --- a/system_wrappers/source/rw_lock_win.h +++ b/rtc_base/synchronization/rw_lock_win.h @@ -8,10 +8,10 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef SYSTEM_WRAPPERS_SOURCE_RW_LOCK_WIN_H_ -#define SYSTEM_WRAPPERS_SOURCE_RW_LOCK_WIN_H_ +#ifndef RTC_BASE_SYNCHRONIZATION_RW_LOCK_WIN_H_ +#define RTC_BASE_SYNCHRONIZATION_RW_LOCK_WIN_H_ -#include "system_wrappers/include/rw_lock_wrapper.h" +#include "rtc_base/synchronization/rw_lock_wrapper.h" #include @@ -20,13 +20,12 @@ namespace webrtc { class RWLockWin : public RWLockWrapper { public: static RWLockWin* Create(); - ~RWLockWin() {} - virtual void AcquireLockExclusive(); - virtual void ReleaseLockExclusive(); + void AcquireLockExclusive() override; + void ReleaseLockExclusive() override; - virtual void AcquireLockShared(); - virtual void ReleaseLockShared(); + void AcquireLockShared() override; + void ReleaseLockShared() override; private: RWLockWin(); @@ -37,4 +36,4 @@ class RWLockWin : public RWLockWrapper { } // namespace webrtc -#endif // SYSTEM_WRAPPERS_SOURCE_RW_LOCK_WIN_H_ +#endif // RTC_BASE_SYNCHRONIZATION_RW_LOCK_WIN_H_ diff --git a/system_wrappers/source/rw_lock.cc b/rtc_base/synchronization/rw_lock_wrapper.cc similarity index 80% rename from system_wrappers/source/rw_lock.cc rename to rtc_base/synchronization/rw_lock_wrapper.cc index c38c44ad75..c8cd17edb8 100644 --- a/system_wrappers/source/rw_lock.cc +++ b/rtc_base/synchronization/rw_lock_wrapper.cc @@ -8,14 +8,14 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "system_wrappers/include/rw_lock_wrapper.h" +#include "rtc_base/synchronization/rw_lock_wrapper.h" #include #if defined(_WIN32) -#include "system_wrappers/source/rw_lock_win.h" +#include "rtc_base/synchronization/rw_lock_win.h" #else -#include "system_wrappers/source/rw_lock_posix.h" +#include "rtc_base/synchronization/rw_lock_posix.h" #endif namespace webrtc { diff --git a/system_wrappers/include/rw_lock_wrapper.h b/rtc_base/synchronization/rw_lock_wrapper.h similarity index 83% rename from system_wrappers/include/rw_lock_wrapper.h rename to rtc_base/synchronization/rw_lock_wrapper.h index a22b6ab9b9..39f52fca35 100644 --- a/system_wrappers/include/rw_lock_wrapper.h +++ b/rtc_base/synchronization/rw_lock_wrapper.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef SYSTEM_WRAPPERS_INCLUDE_RW_LOCK_WRAPPER_H_ -#define SYSTEM_WRAPPERS_INCLUDE_RW_LOCK_WRAPPER_H_ +#ifndef RTC_BASE_SYNCHRONIZATION_RW_LOCK_WRAPPER_H_ +#define RTC_BASE_SYNCHRONIZATION_RW_LOCK_WRAPPER_H_ #include "rtc_base/thread_annotations.h" @@ -35,7 +35,8 @@ class RTC_LOCKABLE RWLockWrapper { // provides more compact locking syntax. class RTC_SCOPED_LOCKABLE ReadLockScoped { public: - ReadLockScoped(RWLockWrapper& rw_lock) RTC_SHARED_LOCK_FUNCTION(rw_lock) + explicit ReadLockScoped(RWLockWrapper& rw_lock) + RTC_SHARED_LOCK_FUNCTION(rw_lock) : rw_lock_(rw_lock) { rw_lock_.AcquireLockShared(); } @@ -48,7 +49,8 @@ class RTC_SCOPED_LOCKABLE ReadLockScoped { class RTC_SCOPED_LOCKABLE WriteLockScoped { public: - WriteLockScoped(RWLockWrapper& rw_lock) RTC_EXCLUSIVE_LOCK_FUNCTION(rw_lock) + explicit WriteLockScoped(RWLockWrapper& rw_lock) + RTC_EXCLUSIVE_LOCK_FUNCTION(rw_lock) : rw_lock_(rw_lock) { rw_lock_.AcquireLockExclusive(); } @@ -61,4 +63,4 @@ class RTC_SCOPED_LOCKABLE WriteLockScoped { } // namespace webrtc -#endif // SYSTEM_WRAPPERS_INCLUDE_RW_LOCK_WRAPPER_H_ +#endif // RTC_BASE_SYNCHRONIZATION_RW_LOCK_WRAPPER_H_ diff --git a/rtc_base/time/BUILD.gn b/rtc_base/time/BUILD.gn index 6c6baa97c6..f8f6244585 100644 --- a/rtc_base/time/BUILD.gn +++ b/rtc_base/time/BUILD.gn @@ -19,6 +19,6 @@ rtc_source_set("timestamp_extrapolator") { ] deps = [ "../..:typedefs", - "../../system_wrappers", + "../synchronization:rw_lock_wrapper", ] } diff --git a/rtc_base/time/timestamp_extrapolator.h b/rtc_base/time/timestamp_extrapolator.h index cd4f5f422f..6638184263 100644 --- a/rtc_base/time/timestamp_extrapolator.h +++ b/rtc_base/time/timestamp_extrapolator.h @@ -11,7 +11,7 @@ #ifndef RTC_BASE_TIME_TIMESTAMP_EXTRAPOLATOR_H_ #define RTC_BASE_TIME_TIMESTAMP_EXTRAPOLATOR_H_ -#include "system_wrappers/include/rw_lock_wrapper.h" +#include "rtc_base/synchronization/rw_lock_wrapper.h" #include "typedefs.h" // NOLINT(build/include) namespace webrtc { diff --git a/system_wrappers/BUILD.gn b/system_wrappers/BUILD.gn index 03e918d00d..d24b16ba6d 100644 --- a/system_wrappers/BUILD.gn +++ b/system_wrappers/BUILD.gn @@ -20,7 +20,6 @@ rtc_static_library("system_wrappers") { "include/event_wrapper.h", "include/ntp_time.h", "include/rtp_to_ntp_estimator.h", - "include/rw_lock_wrapper.h", "include/sleep.h", "source/clock.cc", "source/cpu_features.cc", @@ -31,11 +30,6 @@ rtc_static_library("system_wrappers") { "source/event_timer_win.cc", "source/event_timer_win.h", "source/rtp_to_ntp_estimator.cc", - "source/rw_lock.cc", - "source/rw_lock_posix.cc", - "source/rw_lock_posix.h", - "source/rw_lock_win.cc", - "source/rw_lock_win.h", "source/sleep.cc", ] @@ -51,6 +45,7 @@ rtc_static_library("system_wrappers") { "../api:optional", "../modules:module_api_public", "../rtc_base:checks", + "../rtc_base/synchronization:rw_lock_wrapper", ] if (is_android) { diff --git a/system_wrappers/include/clock.h b/system_wrappers/include/clock.h index aec5ca5be9..0164288785 100644 --- a/system_wrappers/include/clock.h +++ b/system_wrappers/include/clock.h @@ -13,8 +13,8 @@ #include +#include "rtc_base/synchronization/rw_lock_wrapper.h" #include "system_wrappers/include/ntp_time.h" -#include "system_wrappers/include/rw_lock_wrapper.h" #include "typedefs.h" // NOLINT(build/include) namespace webrtc { diff --git a/system_wrappers/source/clock.cc b/system_wrappers/source/clock.cc index 631974d9bc..e9ae82fd12 100644 --- a/system_wrappers/source/clock.cc +++ b/system_wrappers/source/clock.cc @@ -25,8 +25,8 @@ #endif // defined(WEBRTC_POSIX) #include "rtc_base/criticalsection.h" +#include "rtc_base/synchronization/rw_lock_wrapper.h" #include "rtc_base/timeutils.h" -#include "system_wrappers/include/rw_lock_wrapper.h" namespace webrtc {