调整gtype中类型值的获取访问名 Get() -> Val()

This commit is contained in:
John
2018-03-27 23:24:45 +08:00
parent b8c993fe25
commit 67832bf26c
14 changed files with 24 additions and 24 deletions

View File

@ -34,6 +34,6 @@ func (t *Bool)Set(value bool) {
}
}
func (t *Bool)Get() bool {
func (t *Bool)Val() bool {
return atomic.LoadInt32(&t.val) > 0
}

View File

@ -28,7 +28,7 @@ func (t *Bytes)Set(value []byte) {
t.mu.Unlock()
}
func (t *Bytes)Get() []byte {
func (t *Bytes)Val() []byte {
t.mu.RLock()
b := t.val
t.mu.RUnlock()

View File

@ -25,7 +25,7 @@ func (t *Float32)Set(value float32) {
atomic.StoreUint32(&t.val, uint32(value))
}
func (t *Float32)Get() int {
func (t *Float32)Val() int {
return int(atomic.LoadUint32(&t.val))
}

View File

@ -25,7 +25,7 @@ func (t *Float64)Set(value float32) {
atomic.StoreUint64(&t.val, uint64(value))
}
func (t *Float64)Get() int {
func (t *Float64)Val() int {
return int(atomic.LoadUint64(&t.val))
}

View File

@ -34,7 +34,7 @@ func BenchmarkInt_Set(b *testing.B) {
func BenchmarkInt_Get(b *testing.B) {
for i := 0; i < b.N; i++ {
it.Get()
it.Val()
}
}
@ -52,7 +52,7 @@ func BenchmarkInt32_Set(b *testing.B) {
func BenchmarkInt32_Get(b *testing.B) {
for i := int32(0); i < int32(b.N); i++ {
it32.Get()
it32.Val()
}
}
@ -70,7 +70,7 @@ func BenchmarkInt64_Set(b *testing.B) {
func BenchmarkInt64_Get(b *testing.B) {
for i := int64(0); i < int64(b.N); i++ {
it64.Get()
it64.Val()
}
}
@ -90,7 +90,7 @@ func BenchmarkUint_Set(b *testing.B) {
func BenchmarkUint_Get(b *testing.B) {
for i := uint(0); i < uint(b.N); i++ {
uit.Get()
uit.Val()
}
}
@ -110,7 +110,7 @@ func BenchmarkUint32_Set(b *testing.B) {
func BenchmarkUint32_Get(b *testing.B) {
for i := uint32(0); i < uint32(b.N); i++ {
uit32.Get()
uit32.Val()
}
}
@ -129,7 +129,7 @@ func BenchmarkUint64_Set(b *testing.B) {
func BenchmarkUint64_Get(b *testing.B) {
for i := uint64(0); i < uint64(b.N); i++ {
uit64.Get()
uit64.Val()
}
}
@ -149,7 +149,7 @@ func BenchmarkBool_Set(b *testing.B) {
func BenchmarkBool_Get(b *testing.B) {
for i := 0; i < b.N; i++ {
bl.Get()
bl.Val()
}
}
@ -163,7 +163,7 @@ func BenchmarkString_Set(b *testing.B) {
func BenchmarkString_Get(b *testing.B) {
for i := 0; i < b.N; i++ {
str.Get()
str.Val()
}
}
@ -177,7 +177,7 @@ func BenchmarkBytes_Set(b *testing.B) {
func BenchmarkBytes_Get(b *testing.B) {
for i := 0; i < b.N; i++ {
bytes.Get()
bytes.Val()
}
}
@ -190,7 +190,7 @@ func BenchmarkInterface_Set(b *testing.B) {
func BenchmarkInterface_Get(b *testing.B) {
for i := 0; i < b.N; i++ {
inf.Get()
inf.Val()
}
}

View File

@ -25,7 +25,7 @@ func (t *Int)Set(value int) {
atomic.StoreInt64(&t.val, int64(value))
}
func (t *Int)Get() int {
func (t *Int)Val() int {
return int(atomic.LoadInt64(&t.val))
}

View File

@ -25,7 +25,7 @@ func (t *Int32)Set(value int32) {
atomic.StoreInt32(&t.val, value)
}
func (t *Int32)Get() int32 {
func (t *Int32)Val() int32 {
return atomic.LoadInt32(&t.val)
}

View File

@ -25,7 +25,7 @@ func (t *Int64)Set(value int64) {
atomic.StoreInt64(&t.val, value)
}
func (t *Int64)Get() int64 {
func (t *Int64)Val() int64 {
return atomic.LoadInt64(&t.val)
}

View File

@ -28,7 +28,7 @@ func (t *Interface)Set(value interface{}) {
t.mu.Unlock()
}
func (t *Interface)Get() interface{} {
func (t *Interface)Val() interface{} {
t.mu.RLock()
b := t.val
t.mu.RUnlock()

View File

@ -28,7 +28,7 @@ func (t *String)Set(value string) {
t.mu.Unlock()
}
func (t *String)Get() string {
func (t *String)Val() string {
t.mu.RLock()
s := t.val
t.mu.RUnlock()

View File

@ -25,7 +25,7 @@ func (t *Uint)Set(value uint) {
atomic.StoreUint64(&t.val, uint64(value))
}
func (t *Uint)Get() uint {
func (t *Uint)Val() uint {
return uint(atomic.LoadUint64(&t.val))
}

View File

@ -25,7 +25,7 @@ func (t *Uint32)Set(value uint32) {
atomic.StoreUint32(&t.val, value)
}
func (t *Uint32)Get() uint32 {
func (t *Uint32)Val() uint32 {
return atomic.LoadUint32(&t.val)
}

View File

@ -25,7 +25,7 @@ func (t *Uint64)Set(value uint64) {
atomic.StoreUint64(&t.val, value)
}
func (t *Uint64)Get() uint64 {
func (t *Uint64)Val() uint64 {
return atomic.LoadUint64(&t.val)
}

View File

@ -292,8 +292,8 @@ func (c *Cache) autoClearLoop() {
c.smu.Unlock()
}
// LRU缓存淘汰处理
if c.cap.Get() > 0 {
for i := c.Size() - c.cap.Get(); i > 0; i-- {
if c.cap.Val() > 0 {
for i := c.Size() - c.cap.Val(); i > 0; i-- {
if s := c.lru.Pop(); s != "" {
c.clearByKey(s)
}