mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-19 16:47:50 +01:00

When a Send is in progress, don't allow modification to the list of callbacks, or a recursive Send. Bug: webrtc:11943 Change-Id: I88751060136972d0c9170db725fa30312a14b5b1 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/192360 Commit-Queue: Karl Wiberg <kwiberg@webrtc.org> Reviewed-by: Niels Moller <nisse@webrtc.org> Reviewed-by: Markus Handell <handellm@webrtc.org> Cr-Commit-Position: refs/heads/master@{#32584}
48 lines
1.5 KiB
C++
48 lines
1.5 KiB
C++
/*
|
|
* Copyright 2020 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.
|
|
*/
|
|
|
|
#include "rtc_base/callback_list.h"
|
|
|
|
#include "rtc_base/checks.h"
|
|
|
|
namespace webrtc {
|
|
namespace callback_list_impl {
|
|
|
|
CallbackListReceivers::CallbackListReceivers() = default;
|
|
|
|
CallbackListReceivers::~CallbackListReceivers() {
|
|
RTC_CHECK(!send_in_progress_);
|
|
}
|
|
|
|
void CallbackListReceivers::Foreach(
|
|
rtc::FunctionView<void(UntypedFunction&)> fv) {
|
|
RTC_CHECK(!send_in_progress_);
|
|
send_in_progress_ = true;
|
|
for (auto& r : receivers_) {
|
|
fv(r);
|
|
}
|
|
send_in_progress_ = false;
|
|
}
|
|
|
|
template void CallbackListReceivers::AddReceiver(
|
|
UntypedFunction::TrivialUntypedFunctionArgs<1>);
|
|
template void CallbackListReceivers::AddReceiver(
|
|
UntypedFunction::TrivialUntypedFunctionArgs<2>);
|
|
template void CallbackListReceivers::AddReceiver(
|
|
UntypedFunction::TrivialUntypedFunctionArgs<3>);
|
|
template void CallbackListReceivers::AddReceiver(
|
|
UntypedFunction::TrivialUntypedFunctionArgs<4>);
|
|
template void CallbackListReceivers::AddReceiver(
|
|
UntypedFunction::NontrivialUntypedFunctionArgs);
|
|
template void CallbackListReceivers::AddReceiver(
|
|
UntypedFunction::FunctionPointerUntypedFunctionArgs);
|
|
|
|
} // namespace callback_list_impl
|
|
} // namespace webrtc
|