Fork me on GitHub

would it be possible to make a version of alts! that takes an iterable of channels instead of a vector?


@schmee alts! really only calls nth on the collection you give it. So it could be an array or a seq, iterables would have to be converted to something that supports nth


this is because alts! requires random access to the collection, because it does some randomization of the data internally. alts! will attempt to operate on channels in a non-deterministic way in order to avoid starving some processes


ahh, I see, maybe you can help me figure out a way to solve the issue I’m expecting


I’m alting over a potentially large vector which is created from the keys of a concurrent hash map. I would like to avoid recreating the vector everytime an element is added or removed from the map since this will be happening a lot


my idea was to maybe use the KeySet for the map somehow but since random access is required I see now why that won’t work


any ideas on how to approach this problem?


@schmee optimizing this won't help a whole lot, since internally alts! will be putting these values into an array and doing other things with them


@schmee perhaps, invert the flow? Have all of these sources put into a common channel instead of trying to alt over a lot of channels?


that might work, I’ll try it out!


thanks for the help 🙂