Skip to content
This repository has been archived by the owner on Jun 19, 2019. It is now read-only.

rows.go的ReflectNew当大数据量时,并发多个请求出现out of range错误 #26

Closed
jacoblai opened this issue Jul 1, 2017 · 1 comment
Labels

Comments

@jacoblai
Copy link

jacoblai commented Jul 1, 2017

func ReflectNew(typ reflect.Type) reflect.Value {
	reflectCacheMutex.RLock()
	cs, ok := reflectCache[typ]
	reflectCacheMutex.RUnlock()

	const newSize = 200

	if !ok || cs.idx+1 > newSize-1 {
		cs = &cacheStruct{reflect.MakeSlice(reflect.SliceOf(typ), newSize, newSize), 0}
		reflectCacheMutex.Lock()
		reflectCache[typ] = cs
		reflectCacheMutex.Unlock()
	} else {
		reflectCacheMutex.Lock()
		cs.idx = cs.idx + 1
		reflectCacheMutex.Unlock()
	}
	//todo 当大数据量时,并发多个请求出现out of range错误
	return cs.value.Index(cs.idx).Addr()
}
@lunny lunny added the bug label Jul 1, 2017
@lunny
Copy link
Member

lunny commented Jan 17, 2019

I think this has been resolved. Please feel free to reopen it.

@lunny lunny closed this as completed Jan 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants