rw_lock.h
Go to the documentation of this file.
00001 #ifndef MT_RW_LOCK_H
00002 #define MT_RW_LOCK_H
00003 
00004 #include "base.h"
00005 
00006 #include <pthread.h>
00007 
00008 namespace mt
00009 {
00010 
00011 class rw_lock
00012 {
00013         MT_PREVENT_COPY(rw_lock)
00014 
00015         public:
00016 
00017                 typedef rw_lock this_type;
00018                 typedef void    base_type;
00019 
00020                 rw_lock(void)
00021                 {
00022                         pthread_rwlock_init(&(this->rw), 0);
00023                 }
00024 
00025                 ~rw_lock(void)
00026                 {
00027                         pthread_rwlock_destroy(&(this->rw));
00028                 }
00029 
00030                 void lock_read(void)
00031                 {
00032                         pthread_rwlock_rdlock(&(this->rw));
00033                 }
00034 
00035                 void unlock_read(void)
00036                 {
00037                         pthread_rwlock_unlock(&(this->rw));
00038                 }
00039 
00040                 void lock_write(void)
00041                 {
00042                         pthread_rwlock_wrlock(&(this->rw));
00043                 }
00044 
00045                 void unlock_write(void)
00046                 {
00047                         pthread_rwlock_unlock(&(this->rw));
00048                 }
00049 
00050         private:
00051 
00052                 pthread_rwlock_t rw;
00053 };
00054 
00055 }
00056 
00057 #endif // MT_RW_LOCK_H


shape_reconstruction
Author(s): Roberto Martín-Martín
autogenerated on Sat Jun 8 2019 18:35:10