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 |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/shmqueue.go b/shmqueue.go
index 8c5b3a4..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(1) * time.Microsecond
+	TimePeriodPutOrGet = time.Duration(5)*time.Millisecond //ms
 )
 
 //Element info
@@ -146,14 +146,14 @@
 func (eqi *EsQueueInfo) QueueSize() int {
 	var putPos, getPos uint32
 	var quantity uint32
+
 	getPos = atomic.LoadUint32(&eqi.Queue.getPos)
 	putPos = atomic.LoadUint32(&eqi.Queue.putPos)
 
 	if putPos >= getPos {
 		quantity = putPos - getPos
 	} else {
-		//quantity = q.capMod + (putPos - getPos)
-		quantity = (eqi.Queue.capMod + (putPos - getPos)) % eqi.Queue.capMod
+		quantity = eqi.Queue.capMod + (putPos - getPos)
 	}
 
 	return int(quantity)
@@ -164,7 +164,8 @@
 	var elems []ElemInfo
 
 	for i := 0; i < len(eqi.EsCaches); i++ {
-		if eqi.EsCaches[i].value.PicId != 0 && eqi.EsCaches[i].value.InfoId != 0 {
+		if eqi.EsCaches[i].value.PicId != -1 && eqi.EsCaches[i].value.InfoId != -1 &&
+			eqi.EsCaches[i].value.PicId != 0 && eqi.EsCaches[i].value.InfoId != 0 {
 			elems = append(elems, eqi.EsCaches[i].value)
 		}
 	}
@@ -184,8 +185,7 @@
 	if putPos >= getPos {
 		posCnt = putPos - getPos
 	} else {
-		//posCnt = capMod + (putPos - getPos)
-		posCnt = (capMod + (putPos - getPos)) % capMod
+		posCnt = capMod + (putPos - getPos)
 	}
 
 	//todo
@@ -300,7 +300,7 @@
 		putNo := atomic.LoadUint32(&cache.putNo)
 		if getPosNew == getNo && getNo == putNo-eqi.Queue.capacity {
 			val := cache.value
-			cache.value = ElemInfo{PicId: 0}
+			cache.value = ElemInfo{PicId: 0, InfoId:0}
 			atomic.AddUint32(&cache.getNo, eqi.Queue.capacity)
 			return val, true, int(posCnt - 1)
 		} else {

--
Gitblit v1.8.0