25 #ifndef __TERVEL_CONTAINERS_LF_MCAS_BUFFER_MCAS_BUFFER_H__
26 #define __TERVEL_CONTAINERS_LF_MCAS_BUFFER_MCAS_BUFFER_H__
39 namespace containers {
41 namespace mcas_buffer {
56 void *
complete(
void *current, std::atomic<void *> *address) {
81 for (uint64_t i = 2; i <
capacity_; i++) {
87 for (uint64_t i = 0; i <
capacity_; i++) {
132 for (uint64_t i = 0; i <
capacity_; i++) {
135 printf(
"[%lu, TAIL(%p) ] ", i, cvalue);
137 printf(
"[%lu, HEAD(%p) ] ", i, cvalue);
139 printf(
"[%lu, NOT(%p) ] ", i, cvalue);
141 printf(
"[%lu, VAL(%p)] ", i, reinterpret_cast<void *>(cvalue->
value()));
158 reinterpret_cast<std::atomic<void *> *
>(&(
buff_[pos])));
165 std::atomic<Node<T> *> *
address(uint64_t pos) {
169 return &(
buff_[pos]);
177 return head_.fetch_add(i);
185 return tail_.fetch_add(i);
212 success = mcas->execute();
259 success = mcas->execute();
281 std::unique_ptr<std::atomic<Node<T> *>[]>
buff_;
292 Node<T> *node = tervel::util::memory::rc::get_descriptor<Node<T>>(value);
305 if (node == c_not_value) {
308 value = node->
value();
319 #endif // __TERVEL_CONTAINERS_LF_MCAS_BUFFER_MCAS_BUFFER_H__
virtual void * get_logical_value()=0
This method is implemented by each sub class.
bool enqueue(T value)
Definition: mcas_buffer.h:291
bool is_empty()
Definition: mcas_buffer.h:105
Node< T > * c_tail_value
Definition: mcas_buffer.h:285
~RingBuffer()
Definition: mcas_buffer.h:86
void free_descriptor(tervel::util::Descriptor *descr, bool dont_check=false)
Once a user is done with a descriptor, they should free it with this method.
Definition: descriptor_util.h:65
TODO(steven):
Definition: mcas.h:36
uint64_t tail(uint64_t i)
Definition: mcas_buffer.h:184
~Node()
Definition: mcas_buffer.h:49
uint64_t head()
Definition: mcas_buffer.h:172
std::atomic< Node< T > * > * address(uint64_t pos)
Definition: mcas_buffer.h:165
Node< T > * dequeue()
enqueue
Definition: mcas_buffer.h:231
T value()
Definition: mcas_buffer.h:51
RingBuffer(uint64_t s)
Definition: mcas_buffer.h:74
Node< T > * c_head_value
Definition: mcas_buffer.h:284
std::unique_ptr< std::atomic< Node< T > * >[]> buff_
Definition: mcas_buffer.h:281
const uint64_t capacity_
Definition: mcas_buffer.h:278
std::atomic< uint64_t > tail_
Definition: mcas_buffer.h:280
Definition: mcas_buffer.h:44
size_t capacity()
Definition: mcas_buffer.h:127
Node< T > * at(uint64_t pos)
Definition: mcas_buffer.h:148
Node(T val)
Definition: mcas_buffer.h:46
This defines the Descriptor class, this class is designed to be extend and be used in conjunction wit...
Definition: descriptor.h:60
uint64_t tail()
Definition: mcas_buffer.h:180
virtual void * complete(void *current, std::atomic< void * > *address)=0
This method is implemented by each sub class and must guarantee that upon return that the descriptor ...
Definition: mcas_helper.h:42
void * get_logical_value()
This method is implemented by each sub class.
Definition: mcas_buffer.h:62
bool is_descriptor_first(void *descr)
This returns whether or not the least significant bit holds a bitmark.
Definition: descriptor_util.h:189
uint64_t head(uint64_t i)
Definition: mcas_buffer.h:176
Node< T > * c_not_value
Definition: mcas_buffer.h:283
Definition: mcas_buffer.h:72
bool enqueue(Node< T > *node)
Definition: mcas_buffer.h:188
const T val_
Definition: mcas_buffer.h:65
void * remove_descriptor(void *expected, std::atomic< void * > *address)
This method is used to remove a descriptor object that is conflict with another threads operation...
Definition: descriptor_util.h:208
bool is_full()
Definition: mcas_buffer.h:116
void * complete(void *current, std::atomic< void * > *address)
This method is implemented by each sub class and must guarantee that upon return that the descriptor ...
Definition: mcas_buffer.h:56
void print_queue()
Definition: mcas_buffer.h:131
std::atomic< uint64_t > head_
Definition: mcas_buffer.h:279