From f584749b2cbe91fe9fb506fa85097499fd2d2521 Mon Sep 17 00:00:00 2001 From: qydysky Date: Mon, 1 Jan 2024 23:06:51 +0800 Subject: [PATCH] 1 --- pool/Pool.go | 6 +++--- pool/Pool_test.go | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pool/Pool.go b/pool/Pool.go index a679b81..a73723b 100644 --- a/pool/Pool.go +++ b/pool/Pool.go @@ -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 { diff --git a/pool/Pool_test.go b/pool/Pool_test.go index ee68142..5ffe16c 100644 --- a/pool/Pool_test.go +++ b/pool/Pool_test.go @@ -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) } } -- 2.39.2