Golang Channel implements a simple memory pool

 GO Channel implements a simple memory pool

/* init */
var memPool = make(chan []byte, 64)
for i := 0; i < 64; i++ {
	memPool <- make([]byte, 128)
}

/* malloc */
newMem := <- memPool

/* free */
memPool <- newMem

Comments

Popular posts from this blog

Python Receiving and parse JSON Data via UDP protocol

ubus lua client method and event registration code demo/example