1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2009 Sun Microsystems
5
* Copyright 2005-2008 Intel Corporation. All Rights Reserved.
7
* This program is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; version 2 of the License.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
#ifndef DRIZZLED_ATOMIC_PTHREAD_TRAITS_H
22
#define DRIZZLED_ATOMIC_PTHREAD_TRAITS_H
31
pthread_mutex_t the_mutex;
34
mutex_wrapper(void): locked(false)
37
(void) pthread_mutex_init(&the_mutex, NULL);
43
pthread_mutex_destroy(&the_mutex);
47
pthread_mutex_lock(&the_mutex);
52
pthread_mutex_unlock(&the_mutex);
57
template<typename T, typename D>
61
mutex_wrapper my_lock;
69
inline value_type fetch_and_add(volatile value_type *value, D addend )
73
value_type ret= *value;
78
inline value_type fetch_and_increment(volatile value_type *value)
82
value_type ret= *value;
87
inline value_type fetch_and_decrement(volatile value_type *value)
91
value_type ret= *value;
96
inline value_type fetch_and_store(volatile value_type *value,
97
value_type new_value )
100
value_type ret= *value;
105
inline value_type compare_and_swap(volatile value_type *value,
106
value_type new_value,
107
value_type comparand )
110
if (*value == comparand)
112
value_type ret= *value;
117
inline value_type fetch(const volatile value_type *value) const volatile
122
inline value_type store_with_release(volatile value_type *value,
123
value_type new_value)
127
value_type ret= *value;
132
}; /* pthread_traits */
135
} /* namespace internal */
136
} /* namespace drizzled */
139
#endif /* DRIZZLED_ATOMIC_PTHREAD_TRAITS_H */