Feathercoin
0.5.0
P2P Digital Currency
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
src
leveldb
port
port_posix.cc
Go to the documentation of this file.
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
static
void
PthreadCall(
const
char
* label,
int
result) {
16
if
(result != 0) {
17
fprintf(stderr,
"pthread %s: %s\n"
, label, strerror(result));
18
abort();
19
}
20
}
21
22
Mutex::Mutex
() { PthreadCall(
"init mutex"
, pthread_mutex_init(&
mu_
, NULL)); }
23
24
Mutex::~Mutex
() { PthreadCall(
"destroy mutex"
, pthread_mutex_destroy(&
mu_
)); }
25
26
void
Mutex::Lock
() { PthreadCall(
"lock"
, pthread_mutex_lock(&
mu_
)); }
27
28
void
Mutex::Unlock
() { PthreadCall(
"unlock"
, pthread_mutex_unlock(&
mu_
)); }
29
30
CondVar::CondVar
(
Mutex
*
mu
)
31
:
mu_
(mu) {
32
PthreadCall(
"init cv"
, pthread_cond_init(&
cv_
, NULL));
33
}
34
35
CondVar::~CondVar
() { PthreadCall(
"destroy cv"
, pthread_cond_destroy(&
cv_
)); }
36
37
void
CondVar::Wait
() {
38
PthreadCall(
"wait"
, pthread_cond_wait(&
cv_
, &
mu_
->
mu_
));
39
}
40
41
void
CondVar::Signal
() {
42
PthreadCall(
"signal"
, pthread_cond_signal(&
cv_
));
43
}
44
45
void
CondVar::SignalAll
() {
46
PthreadCall(
"broadcast"
, pthread_cond_broadcast(&
cv_
));
47
}
48
49
void
InitOnce
(
OnceType
* once,
void
(*initializer)()) {
50
PthreadCall(
"once"
, pthread_once(once, initializer));
51
}
52
53
}
// namespace port
54
}
// namespace leveldb
leveldb::port::CondVar::cv_
pthread_cond_t cv_
Definition:
port_posix.h:115
leveldb::port::Mutex::mu_
pthread_mutex_t mu_
Definition:
port_posix.h:100
leveldb
Definition:
builder.cc:15
leveldb::port::CondVar::mu_
Mutex * mu_
Definition:
port_posix.h:116
leveldb::port::CondVar::~CondVar
~CondVar()
Definition:
port_posix.cc:35
leveldb::port::Mutex::Unlock
void Unlock()
Definition:
port_posix.cc:28
logging.h
leveldb::port::Mutex::Lock
void Lock()
Definition:
port_posix.cc:26
mu_
port::Mutex mu_
Definition:
db_test.cc:31
leveldb::port::CondVar::Wait
void Wait()
Definition:
port_posix.cc:37
leveldb::port::InitOnce
void InitOnce(port::OnceType *, void(*initializer)())
Definition:
port_posix.cc:49
leveldb::port::Mutex::~Mutex
~Mutex()
Definition:
port_posix.cc:24
leveldb::port::CondVar::SignalAll
void SignalAll()
Definition:
port_posix.cc:45
leveldb::port::CondVar::Signal
void Signal()
Definition:
port_posix.cc:41
mu
port::Mutex mu
Definition:
db_bench.cc:270
leveldb::port::Mutex::Mutex
Mutex()
Definition:
port_posix.cc:22
leveldb::port::Mutex
Definition:
port_example.h:26
leveldb::port::CondVar::CondVar
CondVar(Mutex *mu)
Definition:
port_posix.cc:30
port_posix.h
leveldb::port::OnceType
Definition:
port_win.h:98
Generated on Thu Sep 11 2014 10:57:06 for Feathercoin by
1.8.8