本文整理匯總了Golang中github.com/fmstephe/flib/queues/spscq.PointerQ類的典型用法代碼示例。如果您正苦於以下問題:Golang PointerQ類的具體用法?Golang PointerQ怎麽用?Golang PointerQ使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了PointerQ類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: pqsEnqueue
func pqsEnqueue(msgCount int64, q *spscq.PointerQ, done chan bool) {
runtime.LockOSThread()
t := 1
var v unsafe.Pointer
for i := int64(0); i < msgCount; i++ {
v = unsafe.Pointer(uintptr(uint(t)))
w := q.WriteSingle(v)
for w == false {
w = q.WriteSingle(v)
}
t++
}
done <- true
}
示例2: pqrwEnqueue
func pqrwEnqueue(msgCount int64, q *spscq.PointerQ, batchSize int64, done chan bool) {
runtime.LockOSThread()
t := int64(1)
buffer := make([]unsafe.Pointer, batchSize)
for t < msgCount {
if batchSize > msgCount-t {
buffer = buffer[:msgCount-t]
}
for i := range buffer {
t++
buffer[i] = unsafe.Pointer(uintptr(uint(t)))
}
for w := false; w == false; w = q.Write(buffer) {
}
}
done <- true
}
示例3: pqarlDequeue
func pqarlDequeue(msgCount int64, q *spscq.PointerQ, batchSize int64, done chan bool) {
runtime.LockOSThread()
start := time.Now().UnixNano()
sum := int64(0)
checksum := int64(0)
t := int64(1)
var buffer []unsafe.Pointer
for t < msgCount {
buffer = q.AcquireRead(batchSize)
for buffer == nil {
buffer = q.AcquireRead(batchSize)
}
for i := range buffer {
t++
sum += int64(uintptr(buffer[i]))
checksum += t
}
q.ReleaseReadLazy()
}
nanos := time.Now().UnixNano() - start
printSummary(msgCount, nanos, q.FailedWrites(), q.FailedReads(), "pqarl")
expect(sum, checksum)
done <- true
}
示例4: pqsDequeue
func pqsDequeue(msgCount int64, q *spscq.PointerQ, done chan bool) {
runtime.LockOSThread()
start := time.Now().UnixNano()
sum := int64(0)
checksum := int64(0)
var v unsafe.Pointer
for i := int64(1); i <= msgCount; i++ {
v = q.ReadSingle()
for v == nil {
v = q.ReadSingle()
}
pv := int64(uintptr(v))
sum += pv
checksum += i
if pv != i {
print(fmt.Sprintf("Bad message. Expected %d, found %d (found-expected = %d)", pv, i, pv-i))
}
}
nanos := time.Now().UnixNano() - start
printSummary(msgCount, nanos, q.FailedWrites(), q.FailedReads(), "pqs")
expect(sum, checksum)
done <- true
}
示例5: pqarlEnqueue
func pqarlEnqueue(msgCount int64, q *spscq.PointerQ, batchSize int64, done chan bool) {
runtime.LockOSThread()
t := int64(1)
var buffer []unsafe.Pointer
for t < msgCount {
size := fmath.Min(batchSize, msgCount-t)
buffer = q.AcquireWrite(size)
for buffer == nil {
buffer = q.AcquireWrite(size)
}
for i := range buffer {
t++
buffer[i] = unsafe.Pointer(uintptr(uint(t)))
}
q.ReleaseWriteLazy()
}
done <- true
}
示例6: pqrwDequeue
func pqrwDequeue(msgCount int64, q *spscq.PointerQ, batchSize int64, done chan bool) {
runtime.LockOSThread()
start := time.Now().UnixNano()
sum := int64(0)
checksum := int64(0)
t := int64(1)
buffer := make([]unsafe.Pointer, batchSize)
for t < msgCount {
if batchSize > msgCount-t {
buffer = buffer[:msgCount-t]
}
for r := false; r == false; r = q.Read(buffer) {
}
for i := range buffer {
t++
sum += int64(uintptr(buffer[i]))
checksum += t
}
}
nanos := time.Now().UnixNano() - start
printSummary(msgCount, nanos, q.FailedWrites(), q.FailedReads(), "pqrw")
expect(sum, checksum)
done <- true
}