From 18705acc13f78ac65458b3dd832545e62fbc9172 Mon Sep 17 00:00:00 2001
From: wangzhengquan <wangzhengquan85@126.com>
Date: 星期一, 08 二月 2021 10:44:29 +0800
Subject: [PATCH] update

---
 src/pread_write_lock.h |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/read_write_lock.h b/src/pread_write_lock.h
similarity index 72%
rename from src/read_write_lock.h
rename to src/pread_write_lock.h
index c899115..ea89cce 100644
--- a/src/read_write_lock.h
+++ b/src/pread_write_lock.h
@@ -1,9 +1,9 @@
-#ifndef _CLOSE_LOCK_H_
-#define _CLOSE_LOCK_H_  
+#ifndef _PREAD_WRITE_LOCK_H_
+#define _PREAD_WRITE_LOCK_H_  
 
 #include "usg_common.h"
 #include "psem.h"
-class ReadWriteLock {
+class PReadWriteLock {
 private:
 	unsigned int readCount = 0;
   sem_t countMutex;
@@ -11,13 +11,17 @@
 
 
 public:
-	ReadWriteLock() {
+	PReadWriteLock() {
+		if (sem_init(&countMutex, 1, 1) == -1)
+    	err_exit(errno, "PReadWriteLock sem_init");
 
+   	if (sem_init(&writeMutex, 1, 1) == -1)
+    	err_exit(errno, "PReadWriteLock sem_init");
 	}
 
 	void lockRead() {
 		//readCount鏄叡浜彉閲忥紝鎵�浠ラ渶瑕佸疄鐜颁竴涓攣鏉ユ帶鍒惰鍐�  
- //synchronized(ReadWriteLock.class){}  
+ //synchronized(PReadWriteLock.class){}  
 	  psem_wait(&countMutex);
     //鍙湁鏄涓�涓鑰咃紝鎵嶅皢鍐欓攣鍔犻攣銆傚叾浠栫殑璇昏�呴兘鏄繘琛屼笅涓�姝�  
     if(readCount == 0){ 

--
Gitblit v1.8.0