sort using mutex from protobuf struct

This commit is contained in:
Jeff Carr 2024-12-01 00:46:06 -06:00
parent 9a34961d3d
commit 3261af8db3
2 changed files with 7 additions and 2 deletions

View File

@ -114,6 +114,7 @@ func main() {
if err := addMutex(sortmap); err == nil { if err := addMutex(sortmap); err == nil {
log.Info("adding mutex to existing protoc-gen-go file worked") log.Info("adding mutex to existing protoc-gen-go file worked")
sortmap["mutex"] = "true" sortmap["mutex"] = "true"
sortmap["lock"] = "all"
} else { } else {
log.Info("adding mutex to existing protoc-gen-go file did not work") log.Info("adding mutex to existing protoc-gen-go file did not work")
sortmap["mutex"] = "false" sortmap["mutex"] = "false"

View File

@ -13,7 +13,12 @@ func makeSortfile() {
f, _ := os.OpenFile(sortmap["protobase"]+".sort.pb.go", os.O_WRONLY|os.O_CREATE, 0600) f, _ := os.OpenFile(sortmap["protobase"]+".sort.pb.go", os.O_WRONLY|os.O_CREATE, 0600)
header(f, sortmap) header(f, sortmap)
syncLock(f, sortmap)
if sortmap["lock"] == "all" {
// if the lock is set to 'all' this means the mutex was put in the protoc-gen-go struct
} else {
syncLock(f, sortmap)
}
iterTop(f, sortmap) iterTop(f, sortmap)
iterNext(f, sortmap) iterNext(f, sortmap)
iterAppend(f, sortmap) // Append() enforce no unique keys iterAppend(f, sortmap) // Append() enforce no unique keys
@ -190,7 +195,6 @@ func iterEnd(w io.Writer, names map[string]string) {
fmt.Fprintln(w, "") fmt.Fprintln(w, "")
fmt.Fprintln(w, " return aStuff") fmt.Fprintln(w, " return aStuff")
fmt.Fprintln(w, "}") fmt.Fprintln(w, "}")
fmt.Fprintln(w, "")
} }
func iterAppend(w io.Writer, names map[string]string) { func iterAppend(w io.Writer, names map[string]string) {