You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.4 KiB
59 lines
1.4 KiB
#ifndef DEPTREE_H |
|
#define DEPTREE_H |
|
#include <set> |
|
#include <vector> |
|
#include <string> |
|
#include <pthread.h> |
|
#include <time.h> |
|
#include "globals.h" |
|
|
|
class DepTree |
|
{ |
|
typedef std::vector<DepTree*> LeafVector; |
|
typedef std::map<std::string,DepTree*> DepTreeVars; |
|
typedef std::set<DepTree*> NodeVector; |
|
typedef std::set<DepTree*> CallStack; |
|
enum NodeType {NOTDEF,ROOT,SAVE,PRINT,VAR}; |
|
|
|
typedef struct |
|
{ |
|
const DepTree* root; |
|
int exitcode; |
|
LeafVector leafs; |
|
pthread_mutex_t leaf_mtx; |
|
pthread_mutex_t root_mtx; |
|
pthread_mutex_t vars_mtx; |
|
pthread_mutex_t prsv_mtx; |
|
pthread_mutex_t tree_mtx; |
|
} thread_params; |
|
|
|
NodeVector parents; |
|
NodeVector childrens; |
|
NodeType type; |
|
G_toType::size_type index; |
|
std::string name; |
|
mutable bool visited; |
|
|
|
int CreateNodeFromVar(const std::string& var, DepTreeVars& vars, CallStack& callstack); |
|
int CreateNodeFromSP(NodeType list, G_toType::size_type ind, DepTreeVars& vars); |
|
LeafVector FindLeafNodes() const; |
|
public: |
|
DepTree():type(DepTree::NOTDEF),visited(false) {} |
|
DepTree(const DepTree&) = delete; |
|
~DepTree() |
|
{ |
|
for(auto& i:parents) i->childrens.erase(this); |
|
for(auto& i:childrens) |
|
{ |
|
i->parents.erase(this); |
|
if(i->parents.size()==0) delete i; |
|
} |
|
} |
|
|
|
int CreateGlobalTree(UsedType& used); |
|
int EvaluateTree(unsigned int nthreads); |
|
friend void* TreeEvaluateM(void* arg); |
|
friend void* TreeEvaluate (void* arg); |
|
}; |
|
|
|
#endif
|
|
|