scroggo@google.com | 4177ef4 | 2012-10-31 15:52:16 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2012 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "SkCondVar.h" |
| 9 | |
| 10 | SkCondVar::SkCondVar() { |
| 11 | pthread_mutex_init(&fMutex, NULL /* default mutex attr */); |
| 12 | pthread_cond_init(&fCond, NULL /* default cond attr */); |
| 13 | } |
| 14 | |
| 15 | SkCondVar::~SkCondVar() { |
| 16 | pthread_mutex_destroy(&fMutex); |
| 17 | pthread_cond_destroy(&fCond); |
| 18 | } |
| 19 | |
| 20 | void SkCondVar::lock() { |
| 21 | pthread_mutex_lock(&fMutex); |
| 22 | } |
| 23 | |
| 24 | void SkCondVar::unlock() { |
| 25 | pthread_mutex_unlock(&fMutex); |
| 26 | } |
| 27 | |
| 28 | void SkCondVar::wait() { |
| 29 | pthread_cond_wait(&fCond, &fMutex); |
| 30 | } |
| 31 | |
| 32 | void SkCondVar::signal() { |
| 33 | pthread_cond_signal(&fCond); |
| 34 | } |
| 35 | |
| 36 | void SkCondVar::broadcast() { |
| 37 | pthread_cond_broadcast(&fCond); |
| 38 | } |