during the process of building a granular synthesis external I arrived at the (debatable) conclusion that the perfect data structure to keep track of the grains is a linked list. So grains can be created and added at any point in the linked list and by the same token deleted. The memory usage is optimal. And the cost of insertion and deletion is constant.
Now, because the linked list must be managed in the perform routine, I am not 100% sure if it’s a good idea to use the ext_linklist.h API or implement a custom, simplified, non thread-safe version in the interest of performance.
Is it safe to use the ext_linklist API in the perform routine?
Would it be a good idea to set the thread-safety mechanism off with the
void linklist_readonly(t_linklist *x, long readonly);
It seems that the zigzag~ external employs a linked list in the perform routine…
What kind of strategy is adopted there? Custom linked list or standard API?
If I were you, I would definitely implement my own lightweight linked list data structure. For one thing, you don’t know what happens inside t_linklist (memory allocations? thread locks?). Moreover, t_linklist is somehow quite "high level" and basic operations tend to be costly: it’s primarily designed to contain Max objects and manage their lifecycle, direct access to its nodes is unrecommended, and it’s a doubly linked list – which you might need or not, and if you don’t it’s more expensive than a singly linked list.
After all, designing a simple linked list data structure is straightforward, and that’s the way I’d go if efficiency is what you need!