-
Notifications
You must be signed in to change notification settings - Fork 0
/
node.hpp
52 lines (47 loc) · 1.34 KB
/
node.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef NODE_HPP
#define NODE_HPP
#include <vector>
#include <iostream>
#include <boost/thread.hpp>
#include <boost/io/ios_state.hpp>
#include <boost/array.hpp>
#include <boost/noncopyable.hpp>
#include <boost/shared_ptr.hpp>
template <typename key, typename value>
struct node : public boost::noncopyable{
typedef node<key,value> node_t;
typedef boost::shared_ptr<node_t> shared_node;
typedef std::vector<shared_node> next_array;
typedef boost::mutex::scoped_lock scoped_lock;
const key first;
value second;
const int top_layer;
boost::mutex guard;
next_array next;
volatile bool marked;
volatile bool fullylinked;
node(const key& k_, const value& v_, size_t top)
:first(k_),second(v_),top_layer(top),next(top+1),marked(false),fullylinked(false){
}
~node(){
//std::cerr << "ptr:" << this << " key:" << k << " value:" << v << " removed\n" ;
}
bool is_valid()const{
return !marked && fullylinked;
}
void dump()const{
std::cerr << "key:" << first << " value:" << second << " lv:" << top_layer << " nexts[";
{
boost::io::ios_flags_saver dec(std::cerr);
for(int i=0;i<=top_layer;i++){
if(next[i] != NULL){
std::cerr << i << ":" << next[i]->first << " ";
}else{
std::cerr << i << ":NULL ";
}
}
}
std::cerr << "] marked:" << marked << " fullylinked:" << fullylinked;
}
} __attribute__((aligned (64)));
#endif