chenshijun
2020-04-24 b4f186a5d496fd2085a2bf1405a6384cd7802236
shmqueue.go
@@ -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)
@@ -185,8 +185,7 @@
   if putPos >= getPos {
      posCnt = putPos - getPos
   } else {
      //posCnt = capMod + (putPos - getPos)
      posCnt = (capMod + (putPos - getPos)) % capMod
      posCnt = capMod + (putPos - getPos)
   }
   //todo
@@ -301,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 {