Hi,
I have a question regarding Odin’s compiler source code. I was curious about some implementation details of the compiler and I can’t figure out how the MPMC queue can be resized? It looks like a Dmitry Vyukov MPMC lock free queue, but this one can apparently get resized which I didn’t know it was possible. Does someone has any clue on how it works?
Function: Odin/src/queue.cpp at 9cf809f329c3cd27eb95c66df9afa7893053cf94 · odin-lang/Odin · GitHub.
To me, I don’t understand how such a queue can be resized. If one thread resize while another is trying to dequeue, the pointers in the dequeue should be invalidated, and the heap allocator used here doesn’t seem to use any tool like a hazard pointer to avoid that. The grow function doesn’t have any guards after the lock to avoid threads resizing multiple times so there might be something I missed here.
I’m sorry, its more an algorithm related question and I’m not sure it is the right place to ask it.