Skip to content

Commit f9713fb

Browse files
ftsuicopybara-github
authored andcommitted
Fix use of deprecated MutexLock.
PiperOrigin-RevId: 876391356
1 parent 92f17e2 commit f9713fb

17 files changed

+84
-84
lines changed

connections/dart/nearby_connections_client_state.cc

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,54 +27,54 @@
2727
namespace nearby::connections::dart {
2828

2929
NC_INSTANCE NearbyConnectionsClientState::GetOpennedService() const {
30-
absl::MutexLock lock(&mutex_);
30+
absl::MutexLock lock(mutex_);
3131
return opened_instance_;
3232
}
3333

3434
void NearbyConnectionsClientState::SetOpennedService(NC_INSTANCE nc_instance) {
35-
absl::MutexLock lock(&mutex_);
35+
absl::MutexLock lock(mutex_);
3636
opened_instance_ = nc_instance;
3737
}
3838

3939
DiscoveryListenerDart*
4040
NearbyConnectionsClientState::GetDiscoveryListenerDart() {
41-
absl::MutexLock lock(&mutex_);
41+
absl::MutexLock lock(mutex_);
4242
return discovery_listener_dart_.get();
4343
}
4444

4545
void NearbyConnectionsClientState::SetDiscoveryListenerDart(
4646
std::unique_ptr<DiscoveryListenerDart> discovery_listener_dart) {
47-
absl::MutexLock lock(&mutex_);
47+
absl::MutexLock lock(mutex_);
4848
discovery_listener_dart_ = std::move(discovery_listener_dart);
4949
}
5050

5151
ConnectionListenerDart*
5252
NearbyConnectionsClientState::GetConnectionListenerDart() {
53-
absl::MutexLock lock(&mutex_);
53+
absl::MutexLock lock(mutex_);
5454
return connection_listener_dart_.get();
5555
}
5656

5757
void NearbyConnectionsClientState::SetConnectionListenerDart(
5858
std::unique_ptr<ConnectionListenerDart> connection_listener_dart) {
59-
absl::MutexLock lock(&mutex_);
59+
absl::MutexLock lock(mutex_);
6060
connection_listener_dart_ = std::move(connection_listener_dart);
6161
}
6262

6363
PayloadListenerDart* NearbyConnectionsClientState::GetPayloadListenerDart() {
64-
absl::MutexLock lock(&mutex_);
64+
absl::MutexLock lock(mutex_);
6565
return payload_listener_dart_.get();
6666
}
6767

6868
void NearbyConnectionsClientState::SetPayloadListenerDart(
6969
std::unique_ptr<PayloadListenerDart> payload_listener_dart) {
70-
absl::MutexLock lock(&mutex_);
70+
absl::MutexLock lock(mutex_);
7171
payload_listener_dart_ = std::move(payload_listener_dart);
7272
}
7373

7474
std::optional<Dart_Port>
7575
NearbyConnectionsClientState::PopNearbyConnectionsApiPort(
7676
NearbyConnectionsApi api) {
77-
absl::MutexLock lock(&mutex_);
77+
absl::MutexLock lock(mutex_);
7878
std::deque<Dart_Port>& port_list = nearby_connections_api_ports_[api];
7979
if (port_list.empty()) {
8080
return std::nullopt;
@@ -87,13 +87,13 @@ NearbyConnectionsClientState::PopNearbyConnectionsApiPort(
8787

8888
void NearbyConnectionsClientState::PushNearbyConnectionsApiPort(
8989
NearbyConnectionsApi api, Dart_Port dart_port) {
90-
absl::MutexLock lock(&mutex_);
90+
absl::MutexLock lock(mutex_);
9191
std::deque<Dart_Port>& port_list = nearby_connections_api_ports_[api];
9292
port_list.push_back(dart_port);
9393
}
9494

9595
void NearbyConnectionsClientState::reset() {
96-
absl::MutexLock lock(&mutex_);
96+
absl::MutexLock lock(mutex_);
9797
opened_instance_ = nullptr;
9898
nearby_connections_api_ports_.clear();
9999
discovery_listener_dart_.reset();

internal/flags/nearby_flags.cc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ NearbyFlags& NearbyFlags::GetInstance() {
3030
}
3131

3232
bool NearbyFlags::GetBoolFlag(const flags::Flag<bool>& flag) {
33-
absl::MutexLock lock(&mutex_);
33+
absl::MutexLock lock(mutex_);
3434

3535
const auto& it = overrided_bool_flag_values_.find(flag.name());
3636
if (it != overrided_bool_flag_values_.end()) {
@@ -44,7 +44,7 @@ bool NearbyFlags::GetBoolFlag(const flags::Flag<bool>& flag) {
4444
}
4545

4646
int64_t NearbyFlags::GetInt64Flag(const flags::Flag<int64_t>& flag) {
47-
absl::MutexLock lock(&mutex_);
47+
absl::MutexLock lock(mutex_);
4848

4949
const auto& it = overrided_int64_flag_values_.find(flag.name());
5050
if (it != overrided_int64_flag_values_.end()) {
@@ -58,7 +58,7 @@ int64_t NearbyFlags::GetInt64Flag(const flags::Flag<int64_t>& flag) {
5858
}
5959

6060
double NearbyFlags::GetDoubleFlag(const flags::Flag<double>& flag) {
61-
absl::MutexLock lock(&mutex_);
61+
absl::MutexLock lock(mutex_);
6262

6363
const auto& it = overrided_double_flag_values_.find(flag.name());
6464
if (it != overrided_double_flag_values_.end()) {
@@ -73,7 +73,7 @@ double NearbyFlags::GetDoubleFlag(const flags::Flag<double>& flag) {
7373

7474
std::string NearbyFlags::GetStringFlag(
7575
const flags::Flag<absl::string_view>& flag) {
76-
absl::MutexLock lock(&mutex_);
76+
absl::MutexLock lock(mutex_);
7777

7878
const auto& it = overrided_string_flag_values_.find(flag.name());
7979
if (it != overrided_string_flag_values_.end()) {
@@ -87,36 +87,36 @@ std::string NearbyFlags::GetStringFlag(
8787
}
8888

8989
void NearbyFlags::SetFlagReader(flags::FlagReader& flag_reader) {
90-
absl::MutexLock lock(&mutex_);
90+
absl::MutexLock lock(mutex_);
9191
flag_reader_ = &flag_reader;
9292
}
9393

9494
void NearbyFlags::OverrideBoolFlagValue(const flags::Flag<bool>& flag,
9595
bool new_value) {
96-
absl::MutexLock lock(&mutex_);
96+
absl::MutexLock lock(mutex_);
9797
overrided_bool_flag_values_[flag.name()] = new_value;
9898
}
9999

100100
void NearbyFlags::OverrideInt64FlagValue(const flags::Flag<int64_t>& flag,
101101
int64_t new_value) {
102-
absl::MutexLock lock(&mutex_);
102+
absl::MutexLock lock(mutex_);
103103
overrided_int64_flag_values_[flag.name()] = new_value;
104104
}
105105

106106
void NearbyFlags::OverrideDoubleFlagValue(const flags::Flag<double>& flag,
107107
double new_value) {
108-
absl::MutexLock lock(&mutex_);
108+
absl::MutexLock lock(mutex_);
109109
overrided_double_flag_values_[flag.name()] = new_value;
110110
}
111111

112112
void NearbyFlags::OverrideStringFlagValue(
113113
const flags::Flag<absl::string_view>& flag, absl::string_view new_value) {
114-
absl::MutexLock lock(&mutex_);
114+
absl::MutexLock lock(mutex_);
115115
overrided_string_flag_values_[flag.name()] = std::string(new_value);
116116
}
117117

118118
void NearbyFlags::ResetOverridedValues() {
119-
absl::MutexLock lock(&mutex_);
119+
absl::MutexLock lock(mutex_);
120120
overrided_bool_flag_values_.clear();
121121
overrided_int64_flag_values_.clear();
122122
overrided_double_flag_values_.clear();

internal/platform/feature_flags.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class FeatureFlags {
137137

138138
// SetFlags for feature controlling
139139
void SetFlags(const Flags& flags) ABSL_LOCKS_EXCLUDED(mutex_) {
140-
absl::MutexLock lock(&mutex_);
140+
absl::MutexLock lock(mutex_);
141141
flags_ = flags;
142142
}
143143

internal/platform/implementation/apple/ble_l2cap_server_socket.mm

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
namespace apple {
2727

2828
BleL2capServerSocket::~BleL2capServerSocket() {
29-
absl::MutexLock lock(&mutex_);
29+
absl::MutexLock lock(mutex_);
3030
DoClose();
3131
}
3232

@@ -36,7 +36,7 @@
3636

3737
// TODO: b/399815436 - Refactor Accept() and AddPendingSocket() for better readability.
3838
std::unique_ptr<api::ble::BleL2capSocket> BleL2capServerSocket::Accept() {
39-
absl::MutexLock lock(&mutex_);
39+
absl::MutexLock lock(mutex_);
4040
while (!closed_ && pending_sockets_.empty()) {
4141
cond_.Wait(&mutex_);
4242
}
@@ -48,7 +48,7 @@
4848
}
4949

5050
bool BleL2capServerSocket::AddPendingSocket(std::unique_ptr<BleL2capSocket> socket) {
51-
absl::MutexLock lock(&mutex_);
51+
absl::MutexLock lock(mutex_);
5252
if (closed_) {
5353
return false;
5454
}
@@ -58,12 +58,12 @@
5858
}
5959

6060
void BleL2capServerSocket::SetCloseNotifier(absl::AnyInvocable<void()> notifier) {
61-
absl::MutexLock lock(&mutex_);
61+
absl::MutexLock lock(mutex_);
6262
close_notifier_ = std::move(notifier);
6363
}
6464

6565
Exception BleL2capServerSocket::Close() {
66-
absl::MutexLock lock(&mutex_);
66+
absl::MutexLock lock(mutex_);
6767
return DoClose();
6868
}
6969

internal/platform/implementation/apple/ble_l2cap_socket.mm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,17 +172,17 @@
172172
peripheral_id_(peripheral_id) {}
173173

174174
BleL2capSocket::~BleL2capSocket() {
175-
absl::MutexLock lock(&mutex_);
175+
absl::MutexLock lock(mutex_);
176176
DoClose();
177177
}
178178

179179
bool BleL2capSocket::IsClosed() const {
180-
absl::MutexLock lock(&mutex_);
180+
absl::MutexLock lock(mutex_);
181181
return closed_;
182182
}
183183

184184
Exception BleL2capSocket::Close() {
185-
absl::MutexLock lock(&mutex_);
185+
absl::MutexLock lock(mutex_);
186186
DoClose();
187187
return {Exception::kSuccess};
188188
}

internal/platform/implementation/apple/ble_medium.mm

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -522,11 +522,11 @@
522522
__block NSError *blockPSMPublishedError = nil;
523523
auto l2cap_server_socket = std::make_unique<BleL2capServerSocket>();
524524
l2cap_server_socket->SetCloseNotifier([this]() {
525-
absl::MutexLock lock(&l2cap_server_socket_mutex_);
525+
absl::MutexLock lock(l2cap_server_socket_mutex_);
526526
l2cap_server_socket_ptr_ = nullptr;
527527
});
528528
{
529-
absl::MutexLock lock(&l2cap_server_socket_mutex_);
529+
absl::MutexLock lock(l2cap_server_socket_mutex_);
530530
l2cap_server_socket_ptr_ = l2cap_server_socket.get();
531531
}
532532
std::string service_id_str = service_id;
@@ -538,7 +538,7 @@
538538
return;
539539
}
540540
{
541-
absl::MutexLock lock(&l2cap_server_socket_mutex_);
541+
absl::MutexLock lock(l2cap_server_socket_mutex_);
542542
if (l2cap_server_socket_ptr_) {
543543
l2cap_server_socket_ptr_->SetPSM(PSM);
544544
}
@@ -558,7 +558,7 @@
558558
callbackQueue:connection_callback_queue_];
559559
auto socket = std::make_unique<BleL2capSocket>(connection);
560560
{
561-
absl::MutexLock lock(&l2cap_server_socket_mutex_);
561+
absl::MutexLock lock(l2cap_server_socket_mutex_);
562562
if (l2cap_server_socket_ptr_) {
563563
l2cap_server_socket_ptr_->AddPendingSocket(std::move(socket));
564564
}
@@ -730,20 +730,20 @@
730730
}
731731

732732
void BleMedium::ClearAdvertisementPacketsMap() {
733-
absl::MutexLock lock(&advertisement_packets_mutex_);
733+
absl::MutexLock lock(advertisement_packets_mutex_);
734734
advertisement_packets_map_.clear();
735735
last_timestamp_to_clean_expired_advertisement_packets_ = [NSDate date];
736736
}
737737

738738
NSDate *BleMedium::GetLastTimestampToCleanExpiredAdvertisementPackets() {
739-
absl::MutexLock lock(&advertisement_packets_mutex_);
739+
absl::MutexLock lock(advertisement_packets_mutex_);
740740
return last_timestamp_to_clean_expired_advertisement_packets_;
741741
}
742742

743743
bool BleMedium::ShouldReportAdvertisement(NSDate *now,
744744
api::ble::BlePeripheral::UniqueId peripheral_id,
745745
NSDictionary<CBUUID *, NSData *> *service_data) {
746-
absl::MutexLock lock(&advertisement_packets_mutex_);
746+
absl::MutexLock lock(advertisement_packets_mutex_);
747747
if (service_data == nil || service_data.count == 0) {
748748
return false;
749749
}
@@ -775,19 +775,19 @@
775775

776776
void BleMedium::AddAdvertisementPacketInfo(api::ble::BlePeripheral::UniqueId peripheral_id,
777777
NSDictionary<CBUUID *, NSData *> *service_data) {
778-
absl::MutexLock lock(&advertisement_packets_mutex_);
778+
absl::MutexLock lock(advertisement_packets_mutex_);
779779
advertisement_packets_map_[peripheral_id] = {[NSDate date], service_data};
780780
}
781781

782782
api::ble::BlePeripheral::UniqueId BleMedium::PeripheralsMap::Add(id<GNCPeripheral> peripheral) {
783-
absl::MutexLock lock(&mutex_);
783+
absl::MutexLock lock(mutex_);
784784
api::ble::BlePeripheral::UniqueId peripheral_id = peripheral.identifier.hash;
785785
peripherals_.insert({peripheral_id, peripheral});
786786
return peripheral_id;
787787
}
788788

789789
id<GNCPeripheral> BleMedium::PeripheralsMap::Get(api::ble::BlePeripheral::UniqueId peripheral_id) {
790-
absl::MutexLock lock(&mutex_);
790+
absl::MutexLock lock(mutex_);
791791
auto peripheral_it = peripherals_.find(peripheral_id);
792792
if (peripheral_it == peripherals_.end()) {
793793
return nil;
@@ -796,7 +796,7 @@
796796
}
797797

798798
void BleMedium::PeripheralsMap::Clear() {
799-
absl::MutexLock lock(&mutex_);
799+
absl::MutexLock lock(mutex_);
800800
peripherals_.clear();
801801
}
802802

internal/platform/implementation/apple/ble_server_socket.mm

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
namespace apple {
2626

2727
BleServerSocket::~BleServerSocket() {
28-
absl::MutexLock lock(&mutex_);
28+
absl::MutexLock lock(mutex_);
2929
DoClose();
3030
}
3131

3232
std::unique_ptr<api::ble::BleSocket> BleServerSocket::Accept() {
33-
absl::MutexLock lock(&mutex_);
33+
absl::MutexLock lock(mutex_);
3434
while (!closed_ && pending_sockets_.empty()) {
3535
cond_.Wait(&mutex_);
3636
}
@@ -42,7 +42,7 @@
4242
}
4343

4444
bool BleServerSocket::Connect(std::unique_ptr<BleSocket> socket) {
45-
absl::MutexLock lock(&mutex_);
45+
absl::MutexLock lock(mutex_);
4646
if (closed_) {
4747
return false;
4848
}
@@ -52,12 +52,12 @@
5252
}
5353

5454
void BleServerSocket::SetCloseNotifier(absl::AnyInvocable<void()> notifier) {
55-
absl::MutexLock lock(&mutex_);
55+
absl::MutexLock lock(mutex_);
5656
close_notifier_ = std::move(notifier);
5757
}
5858

5959
Exception BleServerSocket::Close() {
60-
absl::MutexLock lock(&mutex_);
60+
absl::MutexLock lock(mutex_);
6161
return DoClose();
6262
}
6363

internal/platform/implementation/apple/ble_socket.mm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,23 +185,23 @@
185185
peripheral_id_(peripheral_id) {}
186186

187187
BleSocket::~BleSocket() {
188-
absl::MutexLock lock(&mutex_);
188+
absl::MutexLock lock(mutex_);
189189
DoClose();
190190
}
191191

192192
bool BleSocket::IsClosed() const {
193-
absl::MutexLock lock(&mutex_);
193+
absl::MutexLock lock(mutex_);
194194
return closed_;
195195
}
196196

197197
Exception BleSocket::Close() {
198-
absl::MutexLock lock(&mutex_);
198+
absl::MutexLock lock(mutex_);
199199
DoClose();
200200
return {Exception::kSuccess};
201201
}
202202

203203
void BleSocket::SetCloseNotifier(absl::AnyInvocable<void()> notifier) {
204-
absl::MutexLock lock(&mutex_);
204+
absl::MutexLock lock(mutex_);
205205
close_notifier_ = std::move(notifier);
206206
}
207207

0 commit comments

Comments
 (0)