crossroads

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

mutexnode (1074B)


      1 #ifndef _MUTEXNODE_
      2 #define _MUTEXNODE_
      3 
      4 #include "ThreadsAndMutexes/mutex/mutex"
      5 #include "error/error"
      6 
      7 class MutexNode {
      8 public:
      9     MutexNode(void *o);
     10     MutexNode(MutexNode const &other);
     11     ~MutexNode();
     12 
     13     MutexNode const &operator=(MutexNode const &other);
     14 
     15     void obj(void *o)                   { _obj = o; }
     16     void *obj() const                   { return _obj; }
     17 
     18     MutexNode *left(MutexNode *l)       { _left = l;  return _left;}
     19     MutexNode *left() const             { return _left; }
     20 
     21     MutexNode *right(MutexNode *r)      { _right = r; return _right; }
     22     MutexNode *right() const            { return _right; }
     23 
     24     void lock()                         { _mutex.lock(); }
     25     void unlock()                       { _mutex.unlock(); }
     26 
     27     Mutex mutex() const                 { return _mutex; }
     28     void mutex(Mutex m)                 { _mutex = m; }
     29 
     30     int weight() const;
     31     int balance() const;
     32 
     33 private:
     34     void copy(MutexNode const &other);
     35     void destroy();
     36 
     37     Mutex _mutex;
     38     void *_obj;
     39     MutexNode *_left, *_right;
     40 };
     41 
     42 #endif