-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtree_node.hpp
46 lines (38 loc) · 1.24 KB
/
tree_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
#ifndef MCP_BASE_TREE_NODE_HEADER
#define MCP_BASE_TREE_NODE_HEADER
#include "lock.hpp"
#include "spinlock.hpp"
namespace base {
class Node{
friend class Combining_Tree;
public:
enum CStatus{
IDLE,
FIRST,
SECOND,
RESULT,
ROOT
};
Node(); // for the root
Node(Node * myParent); // non-root Node
Node* getParent(); // get the parent node of this node
private:
/*static const int pad_size = 128 - ( sizeof(bool) + sizeof(CStatus) + sizeof(int)*3 + sizeof(Node*) + sizeof(ConditionVar) + sizeof(Mutex));
*/
bool locked_; // locked status on this node
enum CStatus cStatus_; // combining status
int firstValue_; // 1st value to combine
int secondValue_; // 2nd value to combine
int result_; // result of combine
Node* parent_; // pointer to parent
ConditionVar cond_var_; // cond_var for node_lock
Mutex node_lock_; // lock on the the node
char padding_[32] ;
// methods
bool pre_combine();
int combine(int combined);
int op(int combined);
void distribute(int prior);
};
}
#endif