News for hackers. Stuff that matters.
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.
Re:Handles Are the Better Pointers by vore on Wednesday June 21, 2023 @06:15PM (#36425439)
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.
Re:Handles Are the Better Pointers by lanstin on Saturday June 24, 2023 @05:10PM (#36462683)
Because I am using them in different go routines and I find Go channels are pretty good at handling the synchronization as well as I can.