Skip to content

Commit

Permalink
core: PATCH V14
Browse files Browse the repository at this point in the history
1. go fmt
  • Loading branch information
Adhityaa Chandrasekar committed Dec 5, 2019
1 parent 426aaba commit 1ed2ae7
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions internal/profiling/buffer/buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ package buffer

import (
"errors"
"math/bits"
"runtime"
"sync"
"sync/atomic"
"unsafe"
"math/bits"
)

type queue struct {
Expand Down Expand Up @@ -144,15 +144,15 @@ func NewCircularBuffer(size uint32) (*CircularBuffer, error) {
}

n := numCircularBufferPairs
if size / numCircularBufferPairs < 8 {
if size/numCircularBufferPairs < 8 {
// If each circular buffer is going to hold less than a very small number
// of items (let's say 8), using multiple circular buffers is very likely
// wasteful. Instead, fallback to one circular buffer holding everything.
n = 1
}

cb := &CircularBuffer{
qp: make([]*queuePair, n),
qp: make([]*queuePair, n),
qpMask: n - 1,
}

Expand All @@ -163,7 +163,7 @@ func NewCircularBuffer(size uint32) (*CircularBuffer, error) {
return cb, nil
}

// Pushes an element in to the circular buffer.
// Push pushes an element in to the circular buffer.
func (cb *CircularBuffer) Push(x interface{}) {
n := atomic.AddUint32(&cb.qpn, 1) & cb.qpMask
q := (*queue)(atomic.LoadPointer(&cb.qp[n].q))
Expand Down Expand Up @@ -226,9 +226,9 @@ func dereferenceAppend(result []interface{}, arr []unsafe.Pointer, from, to uint
return result
}

// Allocates and returns an array of things Pushed in to the circular buffer.
// Push order is not maintained; that is, if B was Pushed after A, drain may
// return B at a lower index than A in the returned array.
// Drain allocates and returns an array of things Pushed in to the circular
// buffer. Push order is not maintained; that is, if B was Pushed after A,
// drain may return B at a lower index than A in the returned array.
func (cb *CircularBuffer) Drain() []interface{} {
cb.mu.Lock()
defer cb.mu.Unlock()
Expand Down

0 comments on commit 1ed2ae7

Please sign in to comment.