/*
 *                            SyncC++
 *
 *          Copyright(c) Haifeng Li <hli@cs.ucr.edu> 2002
 *                       All Rights Reserved
 *
 */

#ifndef __HLI_RWLOCK_H
#define __HLI_RWLOCK_H

#include <pthread.h>

class rwlock
{
public:
  rwlock()
    { pthread_rwlock_init( &_rwlock, 0 ); }
    
  ~rwlock()
    { pthread_rwlock_destroy( &_rwlock ); }

  void rlock()
    { pthread_rwlock_rdlock( &_rwlock ); }

  void wlock()
    { pthread_rwlock_wrlock( &_rwlock ); }

  void unlock()
    { pthread_rwlock_unlock( &_rwlock ); }

private:

  // prevent copying
  rwlock(const rwlock&);

  rwlock& operator = (const rwlock&);

  pthread_rwlock_t _rwlock;

}; // class rwlock


#endif // __HLI_RWLOCK_H