#ifndef DEPTREE_H #define DEPTREE_H #include #include #include #include #include #include "globals.h" class DepTree { typedef std::vector LeafVector; typedef std::map DepTreeVars; typedef std::set NodeVector; typedef std::set 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