mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-19 00:27:51 +01:00

This will be used by simulated time controller to allow processing other tasks while waiting on an Event. This makes posting of blocking tasks possible. Bug: webrtc:10365 Change-Id: Ic3fb156d545eed2c036939121b89295433176e26 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/128121 Commit-Queue: Sebastian Jansson <srte@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Cr-Commit-Position: refs/heads/master@{#27214}
32 lines
959 B
C++
32 lines
959 B
C++
/*
|
|
* Copyright 2019 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/synchronization/yield_policy.h"
|
|
|
|
#include "absl/base/attributes.h"
|
|
|
|
namespace rtc {
|
|
namespace {
|
|
ABSL_CONST_INIT thread_local YieldInterface* current_yield_policy = nullptr;
|
|
}
|
|
|
|
ScopedYieldPolicy::ScopedYieldPolicy(YieldInterface* policy)
|
|
: previous_(current_yield_policy) {
|
|
current_yield_policy = policy;
|
|
}
|
|
|
|
ScopedYieldPolicy::~ScopedYieldPolicy() {
|
|
current_yield_policy = previous_;
|
|
}
|
|
|
|
void ScopedYieldPolicy::YieldExecution() {
|
|
if (current_yield_policy)
|
|
current_yield_policy->YieldExecution();
|
|
}
|
|
} // namespace rtc
|