blob: 409eb49bf5bf7b71e8e6f6cc22d0f9a7a950c158 [file] [log] [blame]
Danil Chapovalov348b08a2019-01-17 13:07:25 +01001/*
2 * Copyright 2019 The WebRTC Project Authors. All rights reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10#include "api/task_queue/task_queue_base.h"
11
12#include "absl/base/attributes.h"
13
14namespace webrtc {
15namespace {
16
17ABSL_CONST_INIT thread_local TaskQueueBase* current = nullptr;
18
19} // namespace
20
21TaskQueueBase* TaskQueueBase::Current() {
22 return current;
23}
24
25TaskQueueBase::CurrentTaskQueueSetter::CurrentTaskQueueSetter(
26 TaskQueueBase* task_queue)
27 : previous_(current) {
28 current = task_queue;
29}
30
31TaskQueueBase::CurrentTaskQueueSetter::~CurrentTaskQueueSetter() {
32 current = previous_;
33}
34
35} // namespace webrtc