good morning!!!!

Skip to content
Snippets Groups Projects
Commit 6cc2918a authored by Garet Halliday's avatar Garet Halliday
Browse files

take in pointers to prevent passing sync.map by value

parent b13a35b4
Branches
No related tags found
No related merge requests found
......@@ -3,7 +3,7 @@ import (
{{range $curCount := iterateFromN 1 .Count}}
type {{template "generictypedef" $curCount}} struct {
inner Map1[K0, {{template "reltypedef" (list (sub $curCount 1) 1)}}]
inner *Map1[K0, {{template "reltypedef" (list (sub $curCount 1) 1 false)}}]
}
func (m *{{template "typedef" $curCount}}) Load({{range $val := (iterateFromN 0 (add $curCount 1)) }}k{{$val}} K{{$val}}, {{end}}
......@@ -44,10 +44,10 @@ value V) {
{{range $subCurCount:= iterateFromN 0 (add $curCount 1)}}
func (m *{{template "typedef" $curCount}}) Load{{$subCurCount}}({{range $val := (iterateFromN 0 (add 1 $subCurCount)) }}k{{$val}} K{{$val}}, {{end}}
) (value {{template "reltypedef" (list (sub (sub $curCount $subCurCount) 1) (add $subCurCount 1))}}, ok bool) {
) (value {{template "reltypedef" (list (sub (sub $curCount $subCurCount) 1) (add $subCurCount 1) false)}}, ok bool) {
item0 := m.inner
{{range $val := (iterateFromN 1 ($subCurCount)) }}
var item{{$val}} {{template "reltypedef" (list (sub $curCount .) .)}}
var item{{$val}} {{template "reltypedef" (list (sub $curCount .) . false)}}
item{{$val}}, ok = item{{sub $val 1}}.Load0(k{{sub $val 1}})
if !ok {
return
......@@ -62,7 +62,7 @@ func (m *{{template "typedef" $curCount}}) Delete{{$subCurCount}}({{range $val :
_ = ok
item0 := m.inner
{{range $val := (iterateFromN 1 ($subCurCount)) }}
var item{{$val}} {{template "reltypedef" (list (sub $curCount .) .)}}
var item{{$val}} {{template "reltypedef" (list (sub $curCount .) . false)}}
item{{$val}}, ok = item{{sub $val 1}}.Load0(k{{sub $val 1}})
if !ok {
return
......@@ -72,12 +72,12 @@ func (m *{{template "typedef" $curCount}}) Delete{{$subCurCount}}({{range $val :
}
func (m *{{template "typedef" $curCount}}) Range{{$subCurCount}}({{range $val := (iterateFromN 0 $subCurCount) }}k{{$val}} K{{$val}}, {{end}}
f func(K{{$subCurCount}}, {{template "reltypedef" (list (sub (sub $curCount $subCurCount) 1) (add $subCurCount 1))}}) bool) {
f func(K{{$subCurCount}}, {{template "reltypedef" (list (sub (sub $curCount $subCurCount) 1) (add $subCurCount 1) false)}}) bool) {
var ok bool
_ = ok
item0 := m.inner
{{range $val := (iterateFromN 1 ($subCurCount)) }}
var item{{$val}} {{template "reltypedef" (list (sub $curCount .) .)}}
var item{{$val}} {{template "reltypedef" (list (sub $curCount .) . false)}}
item{{$val}}, ok = item{{sub $val 1}}.Load0(k{{sub $val 1}})
if !ok {
return
......@@ -87,10 +87,10 @@ f func(K{{$subCurCount}}, {{template "reltypedef" (list (sub (sub $curCount $sub
}
func (m *{{template "typedef" $curCount}}) LoadAndDelete{{$subCurCount}}({{range $val := (iterateFromN 0 (add 1 $subCurCount)) }}k{{$val}} K{{$val}}, {{end}}
) (value {{template "reltypedef" (list (sub (sub $curCount $subCurCount) 1) (add $subCurCount 1))}}, loaded bool) {
) (value {{template "reltypedef" (list (sub (sub $curCount $subCurCount) 1) (add $subCurCount 1) false)}}, loaded bool) {
item0 := m.inner
{{range $val := (iterateFromN 1 ($subCurCount)) }}
var item{{$val}} {{template "reltypedef" (list (sub $curCount .) .)}}
var item{{$val}} {{template "reltypedef" (list (sub $curCount .) . false)}}
item{{$val}}, loaded = item{{sub $val 1}}.Load0(k{{sub $val 1}})
if !loaded {
return
......@@ -100,21 +100,21 @@ func (m *{{template "typedef" $curCount}}) LoadAndDelete{{$subCurCount}}({{range
}
func (m *{{template "typedef" $curCount}}) LoadOrStore{{$subCurCount}}({{range $val := (iterateFromN 0 (add 1 $subCurCount)) }}k{{$val}} K{{$val}}, {{end}}
v {{template "reltypedef" (list (sub (sub $curCount $subCurCount) 1) (add $subCurCount 1))}}) (value {{template "reltypedef" (list (sub (sub $curCount $subCurCount) 1) (add $subCurCount 1))}}, loaded bool) {
v {{template "reltypedef" (list (sub (sub $curCount $subCurCount) 1) (add $subCurCount 1) false)}}) (value {{template "reltypedef" (list (sub (sub $curCount $subCurCount) 1) (add $subCurCount 1) false)}}, loaded bool) {
item0 := m.inner
{{range $val := (iterateFromN 1 ($subCurCount)) }}
var item{{$val}} {{template "reltypedef" (list (sub $curCount .) .)}}
item{{$val}}, _ = item{{sub $val 1}}.LoadOrStore0(k{{sub $val 1}}, {{template "reltypedef" (list (sub $curCount .) .)}}{})
var item{{$val}} {{template "reltypedef" (list (sub $curCount .) . false)}}
item{{$val}}, _ = item{{sub $val 1}}.LoadOrStore0(k{{sub $val 1}}, {{template "reltypedef" (list (sub $curCount .) . true)}}{})
{{end}}
return item{{$subCurCount}}.LoadOrStore0(k{{$subCurCount}}, v)
}
func (m *{{template "typedef" $curCount}}) Store{{$subCurCount}}({{range $val := (iterateFromN 0 (add 1 $subCurCount)) }}k{{$val}} K{{$val}}, {{end}}
value {{template "reltypedef" (list (sub (sub $curCount $subCurCount) 1) (add $subCurCount 1))}}) {
value {{template "reltypedef" (list (sub (sub $curCount $subCurCount) 1) (add $subCurCount 1) false)}}) {
item0 := m.inner
{{range $val := (iterateFromN 1 ($subCurCount)) }}
var item{{$val}} {{template "reltypedef" (list (sub $curCount .) .)}}
item{{$val}}, _ = item{{sub $val 1}}.LoadOrStore0(k{{sub $val 1}}, {{template "reltypedef" (list (sub $curCount .) .)}}{})
var item{{$val}} {{template "reltypedef" (list (sub $curCount .) . false)}}
item{{$val}}, _ = item{{sub $val 1}}.LoadOrStore0(k{{sub $val 1}}, {{template "reltypedef" (list (sub $curCount .) . true)}}{})
{{end}}
item{{$subCurCount}}.Store0(k{{$subCurCount}}, value)
}
......
This diff is collapsed.
{{$count := (index . 0) -}}
{{$offset := (index . 1) -}}
{{$make := (index . 2) -}}
{{if eq $count -1 -}}
V
{{- else -}}
Map{{add 1 $count}}[
{{if $make}}&{{else}}*{{end}}Map{{add 1 $count}}[
{{- range $val := iterateFromN $offset (add 1 $count) -}}
K{{$val}},
{{- end -}}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment