2 * Copyright (C) 2015 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
23 pthread_cond_init(&cond_, nullptr);
27 pthread_cond_destroy(&cond_);
30 void Thread::WaitForReady() {
31 pthread_mutex_lock(&mutex_);
33 pthread_cond_wait(&cond_, &mutex_);
35 pthread_mutex_unlock(&mutex_);
38 void Thread::WaitForPending() {
39 pthread_mutex_lock(&mutex_);
41 pthread_cond_wait(&cond_, &mutex_);
43 pthread_mutex_unlock(&mutex_);
46 void Thread::SetPending() {
47 pthread_mutex_lock(&mutex_);
49 pthread_mutex_unlock(&mutex_);
50 pthread_cond_signal(&cond_);
53 void Thread::ClearPending() {
54 pthread_mutex_lock(&mutex_);
56 pthread_mutex_unlock(&mutex_);
57 pthread_cond_signal(&cond_);
60 Action* Thread::CreateAction(uintptr_t key_pointer, const char* type, const char* line) {
61 return Action::CreateAction(key_pointer, type, line, action_memory_);