Исходники и презентации
This commit is contained in:
24
lessons/allocator/arena_problem_1/main.go
Normal file
24
lessons/allocator/arena_problem_1/main.go
Normal file
@ -0,0 +1,24 @@
|
||||
package main
|
||||
|
||||
// GOEXPERIMENT=arenas go run main.go
|
||||
// go run -tags goexperiment.arenas main.go
|
||||
|
||||
import (
|
||||
"arena"
|
||||
)
|
||||
|
||||
type Data struct {
|
||||
value int
|
||||
operaions []int
|
||||
}
|
||||
|
||||
func main() {
|
||||
a := arena.NewArena()
|
||||
defer a.Free()
|
||||
|
||||
// Arenas will not allocate all reference types automatically
|
||||
operations := arena.MakeSlice[int](a, 0, 100)
|
||||
data := arena.New[Data](a)
|
||||
data.operaions = operations
|
||||
_ = data
|
||||
}
|
||||
Reference in New Issue
Block a user