]> 127.0.0.1 Git - part/.git/commitdiff
1 v0.28.20240101151147
authorqydysky <qydysky@foxmail.com>
Mon, 1 Jan 2024 15:06:51 +0000 (23:06 +0800)
committerqydysky <qydysky@foxmail.com>
Mon, 1 Jan 2024 15:06:51 +0000 (23:06 +0800)
pool/Pool.go
pool/Pool_test.go

index a679b817c1db814fa28107a466d4ba038370794b..a73723b352e5a9aed976d14bd62393419b5472c1 100644 (file)
@@ -46,12 +46,12 @@ func New[T any](NewF func() *T, InUse func(*T) bool, ReuseF func(*T) *T, PoolF f
 // Deprecated: s
 func (t *Buf[T]) PoolState() (states []any) {
        state := t.State()
-       return []any{state.pooled, state.nopooled, state.inuse, state.nouse, state.sum, state.getPerSec}
+       return []any{state.Pooled, state.Nopooled, state.Inuse, state.Nouse, state.Sum, state.GetPerSec}
 }
 
 type BufState struct {
-       pooled, nopooled, inuse, nouse, sum int
-       getPerSec                           float64
+       Pooled, Nopooled, Inuse, Nouse, Sum int
+       GetPerSec                           float64
 }
 
 func (t *Buf[T]) State() BufState {
index ee6814296d1b979d143e22b567e2ebaa64588a18..5ffe16c52c893aa44ea57e4219541123d30da2e2 100644 (file)
@@ -38,8 +38,8 @@ func Test1(t *testing.T) {
                b.Get()
        }
        time.Sleep(time.Millisecond * 1100)
-       if math.Abs(b.State().getPerSec-7.5) > 2.5 {
-               t.Fatal(b.State().getPerSec)
+       if math.Abs(b.State().GetPerSec-7.5) > 2.5 {
+               t.Fatal(b.State().GetPerSec)
        }
 }
 
@@ -72,7 +72,7 @@ func TestXxx(t *testing.T) {
        var c2p = uintptr(unsafe.Pointer(c2))
        c2.d = append(c2.d, []byte("2")...)
 
-       if c1p == c2p || bytes.Equal(c1.d, c2.d) || b.State().inuse != 0 || b.State().sum != 0 {
+       if c1p == c2p || bytes.Equal(c1.d, c2.d) || b.State().Inuse != 0 || b.State().Sum != 0 {
                t.Fatal()
        }
 
@@ -81,13 +81,13 @@ func TestXxx(t *testing.T) {
        var c3 = b.Get()
        var c3p = uintptr(unsafe.Pointer(c3))
 
-       if c1p == c3p || len(c1.d) == 0 || b.State().inuse != 0 || b.State().sum != 0 {
+       if c1p == c3p || len(c1.d) == 0 || b.State().Inuse != 0 || b.State().Sum != 0 {
                t.Fatal()
        }
 
        b.Put(c1)
 
-       if len(c1.d) == 0 || b.State().inuse != 0 || b.State().sum != 1 {
-               t.Fatal(len(c1.d) != 0, b.State().inuse != 0, b.State().sum != 1)
+       if len(c1.d) == 0 || b.State().Inuse != 0 || b.State().Sum != 1 {
+               t.Fatal(len(c1.d) != 0, b.State().Inuse != 0, b.State().Sum != 1)
        }
 }