00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifdef MULTI_THREAD_RWL
00027
00028 #ifdef WIN_NT
00029 #include "pthread.h"
00030 #else
00031 #include <pthread.h>
00032 #endif
00033
00034 typedef struct
00035 {
00036 int havelock ;
00037 int writers ;
00038 pthread_mutex_t lock ;
00039 pthread_cond_t waiting ;
00040 }
00041 rw_lock ;
00042
00043 extern rw_lock trie_rw_lock ;
00044
00045 void rw_lock_init(rw_lock *l) ;
00046 void rw_lock_read(rw_lock *l) ;
00047 void rw_unlock_read(rw_lock *l) ;
00048 void rw_lock_write(rw_lock *l) ;
00049 void rw_unlock_write(rw_lock *l) ;
00050
00051 #define TRIE_R_LOCK() \
00052 { if( !th->trie_locked ) \
00053 { th->trie_locked = 1 ; \
00054 rw_lock_read( &trie_rw_lock ) ; \
00055 } }
00056
00057 #define TRIE_R_UNLOCK() \
00058 { if( th->trie_locked ) \
00059 { th->trie_locked = 0 ; \
00060 rw_unlock_read( &trie_rw_lock );\
00061 } }
00062
00063 #define TRIE_W_LOCK() \
00064 rw_lock_write(&trie_rw_lock);
00065 #define TRIE_W_UNLOCK() \
00066 rw_unlock_write(&trie_rw_lock);
00067 #else
00068
00069 #define TRIE_R_LOCK()
00070 #define TRIE_R_UNLOCK()
00071 #define TRIE_W_LOCK()
00072 #define TRIE_W_UNLOCK()
00073
00074 #endif
00075