action: add clock vector field, destructor
[cdsspec-compiler.git] / action.h
1 #ifndef __ACTION_H__
2 #define __ACTION_H__
3
4 #include <list>
5 #include "threads.h"
6 #include "libatomic.h"
7 #include "mymemory.h"
8 #define VALUE_NONE -1
9
10 typedef enum action_type {
11         THREAD_CREATE,
12         THREAD_YIELD,
13         THREAD_JOIN,
14         ATOMIC_READ,
15         ATOMIC_WRITE
16 } action_type_t;
17
18 /* Forward declaration */
19 class Node;
20 class ClockVector;
21
22 class ModelAction {
23 public:
24         ModelAction(action_type_t type, memory_order order, void *loc, int value);
25         ~ModelAction();
26         void print(void);
27
28         thread_id_t get_tid() { return tid; }
29         action_type get_type() { return type; }
30         memory_order get_mo() { return order; }
31         void * get_location() { return location; }
32         int get_seq_number() const { return seq_number; }
33
34         Node * get_node() { return node; }
35         void set_node(Node *n) { node = n; }
36
37         bool is_read();
38         bool is_write();
39         bool is_acquire();
40         bool is_release();
41         bool same_var(ModelAction *act);
42         bool same_thread(ModelAction *act);
43         bool is_dependent(ModelAction *act);
44
45         inline bool operator <(const ModelAction& act) const {
46                 return get_seq_number() < act.get_seq_number();
47         }
48         inline bool operator >(const ModelAction& act) const {
49                 return get_seq_number() > act.get_seq_number();
50         }
51
52         MEMALLOC
53 private:
54         action_type type;
55         memory_order order;
56         void *location;
57         thread_id_t tid;
58         int value;
59         Node *node;
60         int seq_number;
61
62         ClockVector *cv;
63 };
64
65 typedef std::list<class ModelAction *> action_list_t;
66
67 #endif /* __ACTION_H__ */