Shaka Player Embedded
thread_event.cc
Go to the documentation of this file.
1 // Copyright 2018 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include "src/debug/thread_event.h"
16 
17 #include "src/debug/thread.h"
18 
19 namespace shaka {
20 
22  : Waitable(name), provider_(nullptr) {}
23 
25 
26 std::thread::id ThreadEventBase::GetProvider() const {
27  Thread* thread = provider_.load(std::memory_order_acquire);
28  if (thread && thread->get_id() == std::thread::id()) {
29  // Once a thread exits, its thread id gets reset.
30  LOG(FATAL) << "Waiting on an event whose provider thread has exited: "
31  << name();
32  }
33  return thread ? thread->get_id() : std::thread::id();
34 }
35 
36 } // namespace shaka
~ThreadEventBase() override
Definition: thread_event.cc:24
const char * name
std::string name() const
Definition: waitable.h:37
ThreadEventBase(const std::string &name)
Definition: thread_event.cc:21
std::thread::id get_id() const
Definition: thread.h:42
std::thread::id GetProvider() const override
Definition: thread_event.cc:26