30 pthread_mutex_t the_mutex;
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>
69 inline value_type add_and_fetch(
volatile value_type *value, D addend )
73 value_type ret= *value;
78 inline value_type fetch_and_add(
volatile value_type *value, D addend )
81 value_type ret= *value;
87 inline value_type fetch_and_increment(
volatile value_type *value)
90 value_type ret= *value;
96 inline value_type fetch_and_decrement(
volatile value_type *value)
99 value_type ret= *value;
105 inline value_type fetch_and_store(
volatile value_type *value,
106 value_type new_value )
109 value_type ret= *value;
115 inline bool compare_and_swap(
volatile value_type *value,
116 value_type new_value,
117 value_type comparand )
120 bool ret= (*value == comparand);
127 inline value_type fetch(
const volatile value_type *value)
const volatile
130 value_type ret= *value;
135 inline value_type store_with_release(
volatile value_type *value,
136 value_type new_value)
140 value_type ret= *value;