~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/atomics.h

* Fixes drizzled's atomics:

- fetch_and_add() was actually add_and_fetch() - fixed to have both methods correct
- compare_and_swap() was incorrect for all traits classes.  Fixed to return a bool
true only when the supplied value is actually swapped
- fixes increment() and decrement() methods and operator+=() in outer atomics class
template to call proper add_and_fetch() methods on traits classes
- Now that above are fixed, removed the hacks in Query_id and TransactionLog to
have query ID and the new transactoin ID start properly at 1.

* Transaction messages sent over replication stream now use
a real transaction ID, managed by drizzled::TransactionServices.  Previously, 
the Query_id was being used, resulting in SELECT statements incrementing the
transaction ID.

* Added a test case to ensure that DDL ops are given a transaction ID and SELECT
ops do not increment the transaction ID.

The transaction ID will be paired with a channel ID to become the global
transaction identifier.  ReplicationServices will manage the pairing of
channel and transaction ID and understand how far a particular subscriber
node has applied.

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
 
59
59
  atomic_impl() : atomic_base<I>(), traits() {}
60
60
 
 
61
  value_type add_and_fetch( D addend )
 
62
  {
 
63
    return traits.add_and_fetch(&this->my_value, addend);
 
64
  }
 
65
 
61
66
  value_type fetch_and_add( D addend )
62
67
  {
63
68
    return traits.fetch_and_add(&this->my_value, addend);
78
83
    return traits.fetch_and_store(&this->my_value, value);
79
84
  }
80
85
 
81
 
  value_type compare_and_swap( value_type value, value_type comparand )
 
86
  bool compare_and_swap( value_type value, value_type comparand )
82
87
  {
83
88
    return traits.compare_and_swap(&this->my_value, value, comparand);
84
89
  }
102
107
public:
103
108
  atomic_impl<I,D,T>& operator+=( D addend )
104
109
  {
105
 
    fetch_and_add(addend)+addend;
 
110
    increment(addend);
106
111
    return *this;
107
112
  }
108
113
 
113
118
    return operator+=(D(0)-addend);
114
119
  }
115
120
 
116
 
  value_type increment() {
117
 
    return fetch_and_add(1)+1;
118
 
  }
119
 
 
120
 
  value_type decrement() {
121
 
    return fetch_and_add(D(-1))-1;
122
 
  }
123
 
 
124
 
 
 
121
  value_type increment()
 
122
  {
 
123
    return add_and_fetch(1);
 
124
  }
 
125
 
 
126
  value_type decrement()
 
127
  {
 
128
    return add_and_fetch(D(-1));
 
129
  }
125
130
};
126
131
 
127
132
} /* namespace internal */