From 47a19e070f57d92aadf52c62361da6ab5397bd4c Mon Sep 17 00:00:00 2001
From: chenshijun <chenshijun@aiotlink.com>
Date: 星期四, 04 六月 2020 16:13:59 +0800
Subject: [PATCH] 将git的shm库变成本地

---
 shmqueue.go |   20 ++++----------------
 1 files changed, 4 insertions(+), 16 deletions(-)

diff --git a/shmqueue.go b/shmqueue.go
index bf6dcfd..33b61e5 100644
--- a/shmqueue.go
+++ b/shmqueue.go
@@ -3,7 +3,7 @@
 import (
 	"context"
 	"fmt"
-	"github.com/gen2brain/shm"
+	shm "basic.com/valib/goshm.git"
 	"reflect"
 	"runtime"
 	"sync/atomic"
@@ -12,7 +12,7 @@
 )
 
 const (
-	TimePeriodPutOrGet = time.Duration(5) * time.Microsecond
+	TimePeriodPutOrGet = time.Duration(5)*time.Millisecond //ms
 )
 
 //Element info
@@ -189,8 +189,8 @@
 	}
 
 	//todo
-	if posCnt >= capMod-1 {
-	//if posCnt >= capMod {
+	//if posCnt >= capMod-1 {
+	if posCnt >= capMod {
 		runtime.Gosched()
 		return false, int(posCnt)
 	}
@@ -204,8 +204,6 @@
 
 	cache = &(eqi.EsCaches[putPosNew&capMod])
 
-	//tryMax := 100
-	//tryCount := 0
 	for {
 		getNo := atomic.LoadUint32(&cache.getNo)
 		putNo := atomic.LoadUint32(&cache.putNo)
@@ -216,10 +214,6 @@
 		} else {
 			runtime.Gosched()
 		}
-		//tryCount++
-		//if tryCount >= tryMax {
-		//	return false, int(posCnt)
-		//}
 	}
 }
 
@@ -301,8 +295,6 @@
 
 	cache = &(eqi.EsCaches[getPosNew&capMod])
 
-	//tryMax := 100
-	//tryCount := 0
 	for {
 		getNo := atomic.LoadUint32(&cache.getNo)
 		putNo := atomic.LoadUint32(&cache.putNo)
@@ -314,10 +306,6 @@
 		} else {
 			runtime.Gosched()
 		}
-		//tryCount++
-		//if tryCount >= tryMax {
-		//	return ElemInfo{}, false, int(posCnt)
-		//}
 	}
 }
 

--
Gitblit v1.8.0