crossroads

Git mirror of https://crossroads.e-tunity.com/
git clone git://git.finwo.net/app/crossroads
Log | Files | Refs | LICENSE

mutextree (713B)


      1 #ifndef _MUTEXTREE_
      2 #define _MUTEXTREE_
      3 
      4 #include "ThreadsAndMutexes/mutexnode/mutexnode"
      5 #include "config/config"
      6 
      7 // This adds verbosity to the below class functions
      8 // #define DEBUG
      9 
     10 class MutexTree {
     11 public:
     12     MutexTree();
     13     MutexTree(MutexTree const &other);
     14     ~MutexTree();
     15 
     16     MutexTree const &operator=(MutexTree const &other);
     17 
     18     void lock(void *o);
     19     void unlock(void *o);
     20 
     21     int weight() const;
     22     int balance() const;
     23 
     24 private:
     25     void locktree();
     26     void unlocktree();
     27     MutexNode *nodelock(void *o, MutexNode *start);
     28     void nodeunlock(void *o, MutexNode *start);
     29 
     30     void copy(MutexTree const &other);
     31     void destroy();
     32 
     33     MutexNode *_root;
     34     Mutex _treelock;
     35 };
     36 
     37 #endif