~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to drizzled/atomic/pthread_traits.h

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2010-10-02 14:17:48 UTC
  • mfrom: (1.1.1 upstream)
  • mto: (2.1.17 sid)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20101002141748-m6vbfbfjhrw1153e
Tags: 2010.09.1802-1
* New upstream release.
* Removed pid-file argument hack.
* Updated GPL-2 address to be new address.
* Directly copy in drizzledump.1 since debian doesn't have sphinx 1.0 yet.
* Link to jquery from libjs-jquery. Add it as a depend.
* Add drizzled.8 symlink to the install files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
67
67
 
68
68
  pthread_traits() {}
69
69
 
 
70
  inline value_type add_and_fetch(volatile value_type *value, D addend )
 
71
  {
 
72
    my_lock.lock();
 
73
    *value += addend;
 
74
    value_type ret= *value;
 
75
    my_lock.unlock();
 
76
    return ret;
 
77
  }
 
78
 
70
79
  inline value_type fetch_and_add(volatile value_type *value, D addend )
71
80
  {
72
81
    my_lock.lock();
 
82
    value_type ret= *value;
73
83
    *value += addend;
74
 
    value_type ret= *value;
75
84
    my_lock.unlock();
76
85
    return ret;
77
86
  }
79
88
  inline value_type fetch_and_increment(volatile value_type *value)
80
89
  {
81
90
    my_lock.lock();
82
 
    *value++;
83
91
    value_type ret= *value;
 
92
    (*value)++;
84
93
    my_lock.unlock();
85
94
    return ret;
86
95
  }
88
97
  inline value_type fetch_and_decrement(volatile value_type *value)
89
98
  {
90
99
    my_lock.lock();
91
 
    *value--;
92
100
    value_type ret= *value;
 
101
    (*value)--;
93
102
    my_lock.unlock();
94
103
    return ret;
95
104
  }
98
107
                                    value_type new_value )
99
108
  {
100
109
    my_lock.lock();
 
110
    value_type ret= *value;
101
111
    *value= new_value;
102
 
    value_type ret= *value;
103
112
    my_lock.unlock();
104
113
    return ret;
105
114
  }
106
115
 
107
 
  inline value_type compare_and_swap(volatile value_type *value,
 
116
  inline bool compare_and_swap(volatile value_type *value,
108
117
                                     value_type new_value,
109
118
                                     value_type comparand )
110
119
  {
111
120
    my_lock.lock();
112
 
    if (*value == comparand)
 
121
    bool ret= (*value == comparand);
 
122
    if (ret)
113
123
      *value= new_value;
114
 
    value_type ret= *value;
115
124
    my_lock.unlock();
116
125
    return ret;
117
126
  }
118
127
 
119
128
  inline value_type fetch(const volatile value_type *value) const volatile
120
129
  {
121
 
    return *value;
 
130
    const_cast<pthread_traits *>(this)->my_lock.lock();
 
131
    value_type ret= *value;
 
132
    const_cast<pthread_traits *>(this)->my_lock.unlock();
 
133
    return ret;
122
134
  }
123
135
 
124
136
  inline value_type store_with_release(volatile value_type *value,