port/port_posix.cc

filter: Statementstmt 65.2% 15 / 23 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 64.0% 16 / 25 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« util/cache.cc ↑ Summary db/log_writer.cc »
1 // Copyright (c) 2011 The LevelDB Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. See the AUTHORS file for names of contributors.
4  
5 #include "port/port_posix.h"
6  
7 #include <cstdlib>
8 #include <stdio.h>
9 #include <string.h>
10 #include "util/logging.h"
11  
12 namespace leveldb {
13 namespace port {
14  
15 516 static void PthreadCall(const char* label, int result) {
16 516 ▶ if (result != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (result != 0) { 0 516 516
17 0 fprintf(stderr, "pthread %s: %s\n", label, strerror(result));
18 0 abort();
19 }
20 516 }
21  
22 140 Mutex::Mutex() { PthreadCall("init mutex", pthread_mutex_init(&mu_, NULL)); }
23  
24 140 Mutex::~Mutex() { PthreadCall("destroy mutex", pthread_mutex_destroy(&mu_)); }
25  
26 101 void Mutex::Lock() { PthreadCall("lock", pthread_mutex_lock(&mu_)); }
27  
28 101 void Mutex::Unlock() { PthreadCall("unlock", pthread_mutex_unlock(&mu_)); }
29  
30 8 CondVar::CondVar(Mutex* mu)
31 8 : mu_(mu) {
32 8 PthreadCall("init cv", pthread_cond_init(&cv_, NULL));
33 8 }
34  
35 8 CondVar::~CondVar() { PthreadCall("destroy cv", pthread_cond_destroy(&cv_)); }
36  
37 0 void CondVar::Wait() {
38 0 PthreadCall("wait", pthread_cond_wait(&cv_, &mu_->mu_));
39 0 }
40  
41 0 void CondVar::Signal() {
42 0 PthreadCall("signal", pthread_cond_signal(&cv_));
43 0 }
44  
45 18 void CondVar::SignalAll() {
46 18 PthreadCall("broadcast", pthread_cond_broadcast(&cv_));
47 18 }
48  
49 }
50 }
« util/cache.cc ↑ Summary db/log_writer.cc »