Re:Handles Are the Better Pointers
by lanstin on Wednesday June 21, 2023 @01:54PM
(#36421970)
in go you can do this with a channel of ununused structs if pulling from the channel hits default branch of select, make a new one. same if adding back to the channel hits default, then free it; else just stick them in the channel and pull them off. eases GC pressure in hot paths. does put a little scheduler pressure.
[ Parent
| on HN ]
Why not just do this with a regular stack and avoid having to deal with the scheduler at all? Try pop from the stack and if the stack is empty, do a new allocation.