Rename methods in ScopedOperationsBatcher * Rename `push_back` to `Add` * Rename the previously overloaded push_back method to `AddWithFinalizer`. This disambiguates the two functions to avoid running into conflicts, as well as clarify the intent. Bug: webrtc:42222804 Change-Id: Ic8471da8d62229d73ac40fbfae813da31d9d97dd Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/460520 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Auto-Submit: Tomas Gunnarsson <tommi@webrtc.org> Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org> Cr-Commit-Position: refs/heads/main@{#47278}
diff --git a/pc/scoped_operations_batcher.cc b/pc/scoped_operations_batcher.cc index b5b277f..eea4157 100644 --- a/pc/scoped_operations_batcher.cc +++ b/pc/scoped_operations_batcher.cc
@@ -70,14 +70,14 @@ } } -void ScopedOperationsBatcher::push_back(absl::AnyInvocable<void() &&> task) { +void ScopedOperationsBatcher::Add(absl::AnyInvocable<void() &&> task) { RTC_DCHECK_RUN_ON(&sequence_checker_); if (task) { tasks_.emplace_back(std::move(task)); } } -void ScopedOperationsBatcher::push_back( +void ScopedOperationsBatcher::AddWithFinalizer( absl::AnyInvocable<absl::AnyInvocable<void() &&>() &&> task) { RTC_DCHECK_RUN_ON(&sequence_checker_); if (task) {
diff --git a/pc/scoped_operations_batcher.h b/pc/scoped_operations_batcher.h index f5c32c1..6a5f905 100644 --- a/pc/scoped_operations_batcher.h +++ b/pc/scoped_operations_batcher.h
@@ -44,8 +44,9 @@ // Queues non-nullptr tasks to be executed on the target thread when the // ScopedOperationsBatcher goes out of scope. - void push_back(absl::AnyInvocable<void() &&> task); - void push_back(absl::AnyInvocable<absl::AnyInvocable<void() &&>() &&> task); + void Add(absl::AnyInvocable<void() &&> task); + void AddWithFinalizer( + absl::AnyInvocable<absl::AnyInvocable<void() &&>() &&> task); private: using BatchedTask =
diff --git a/pc/scoped_operations_batcher_unittest.cc b/pc/scoped_operations_batcher_unittest.cc index 03aa42d..d8699967 100644 --- a/pc/scoped_operations_batcher_unittest.cc +++ b/pc/scoped_operations_batcher_unittest.cc
@@ -30,7 +30,7 @@ { ScopedOperationsBatcher batcher(target_thread.get()); - batcher.push_back([&] { + batcher.Add([&] { task_executed = true; target_checked = target_thread->IsCurrent(); }); @@ -66,7 +66,7 @@ return_task_thread = Thread::Current(); }; }; - batcher.push_back(std::move(task)); + batcher.AddWithFinalizer(std::move(task)); } EXPECT_TRUE(task_executed); @@ -83,15 +83,15 @@ { ScopedOperationsBatcher batcher(target_thread.get()); - batcher.push_back([&] { execution_order.push_back(1); }); - batcher.push_back([&] { + batcher.Add([&] { execution_order.push_back(1); }); + batcher.Add([&] { execution_order.push_back(2); // Post a task that should interrupt the batch since we now yield to any // pending task. target_thread->PostTask([&] { execution_order.push_back(3); }); }); - batcher.push_back([&] { execution_order.push_back(4); }); - batcher.push_back([&] { execution_order.push_back(5); }); + batcher.Add([&] { execution_order.push_back(4); }); + batcher.Add([&] { execution_order.push_back(5); }); } // Expect the task (3) to execute immediately after the task
diff --git a/pc/sdp_offer_answer.cc b/pc/sdp_offer_answer.cc index e4e996f..5a3ce99 100644 --- a/pc/sdp_offer_answer.cc +++ b/pc/sdp_offer_answer.cc
@@ -2414,17 +2414,17 @@ if (content->rejected && !transceiver->stopped()) { RTC_LOG(LS_INFO) << "Stopping transceiver for MID=" << content->mid() << " since the media section was rejected."; - worker_tasks.push_back(transceiver->GetStopTransceiverProcedure()); + worker_tasks.Add(transceiver->GetStopTransceiverProcedure()); } if (!content->rejected && RtpTransceiverDirectionHasRecv(local_direction)) { if (!media_desc->streams().empty() && media_desc->streams()[0].has_ssrcs()) { uint32_t ssrc = media_desc->streams()[0].first_ssrc(); - worker_tasks.push_back( + worker_tasks.Add( transceiver->receiver_internal()->GetSetupForMediaChannel(ssrc)); } else { - worker_tasks.push_back(transceiver->receiver_internal() - ->GetSetupForUnsignaledMediaChannel()); + worker_tasks.Add(transceiver->receiver_internal() + ->GetSetupForUnsignaledMediaChannel()); } } } @@ -3484,7 +3484,7 @@ if (transceiver->internal()->reused_for_addtrack()) { transceiver->internal()->set_created_by_addtrack(true); } else { - worker_tasks.push_back( + worker_tasks.Add( transceiver->internal()->GetStopTransceiverProcedure()); transceivers()->Remove(transceiver); } @@ -4094,7 +4094,7 @@ // is not already stopped, SDP munging has happened and we need to // ensure the transceiver is stopped. if (!transceiver->internal()->stopped()) { - worker_tasks.push_back( + worker_tasks.Add( transceiver->internal()->GetStopTransceiverProcedure()); } RTC_DCHECK(transceiver->internal()->stopped());