I realize this is maybe a tired topic but I haven’t yet seen a satisfactory solution for my problem. I’ve read that there are other approaches to take, arenas, etc etc. But my goal is to allocate my nodes in one thread then push them into another thread using a sync_channel, then add them, sometimes with insertion sort, into a list in another thread where I cannot allocate [“realtime” audio]. None of the other approaches I’ve seen help me there.
I’ve taken the fifth, double linked list, example from the too many lists blog post and extracted the node allocation from the push and now I want to do insert. I realize that it is problematic but I am not afraid to use unsafe, I’m just not exactly sure how:
I can get to the location I need to insert but as my reference isn’t mutable I can’t modify it, but if I to traverse with a mutable reference I cannot advance as I have to use the mutable reference to update the mutable reference.
It seems like what I have is almost there but I just need that last little bit of help. Do I need UnsafeCell to be able to update a link within my list? Is there some mem op I can do to traverse and keep my link mutable, or some sneaky unsafe cast I can do to take my immutable link and make it mutable?