Danil Chapovalov | 348b08a | 2019-01-17 13:07:25 +0100 | [diff] [blame^] | 1 | /* |
| 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 | |
| 14 | namespace webrtc { |
| 15 | namespace { |
| 16 | |
| 17 | ABSL_CONST_INIT thread_local TaskQueueBase* current = nullptr; |
| 18 | |
| 19 | } // namespace |
| 20 | |
| 21 | TaskQueueBase* TaskQueueBase::Current() { |
| 22 | return current; |
| 23 | } |
| 24 | |
| 25 | TaskQueueBase::CurrentTaskQueueSetter::CurrentTaskQueueSetter( |
| 26 | TaskQueueBase* task_queue) |
| 27 | : previous_(current) { |
| 28 | current = task_queue; |
| 29 | } |
| 30 | |
| 31 | TaskQueueBase::CurrentTaskQueueSetter::~CurrentTaskQueueSetter() { |
| 32 | current = previous_; |
| 33 | } |
| 34 | |
| 35 | } // namespace webrtc |