Thank you! This post has been very illuminating for me. I have read the link on structural concurrency, and it made perfect sense. To the degree that I thought “How come I did not think of this on my own sooner?”.
The idea of a thread bundle with no main thread but with a staggered connection thread launcher thread for the Happy Eyeballs and a growing number of connection threads makes sense to me. A potential implementation could look like follows (I used a java-like pseudocode):
ConnectionSlot connection_slot = new ConnectionSlot(1); // a thread-safe connection slot for 1 element
connector(destination, connection_slot) = {connection = connect(destination); try {connection_slot = connection; cancel_bundle();} catch{connection.close();}} // a function that attempts a connection
launcher(destination_list, connection_slot) = {foreach destination in destination_list {spawn(connector(destination, connection_slot); sleep();}} // a function that keeps spawning connections until canceled
Thank you! This post has been very illuminating for me. I have read the link on structural concurrency, and it made perfect sense. To the degree that I thought “How come I did not think of this on my own sooner?”.
The idea of a thread bundle with no main thread but with a staggered connection thread launcher thread for the Happy Eyeballs and a growing number of connection threads makes sense to me. A potential implementation could look like follows (I used a java-like pseudocode):
ConnectionSlot connection_slot = new ConnectionSlot(1); // a thread-safe connection slot for 1 element
connector(destination, connection_slot) = {connection = connect(destination); try {connection_slot = connection; cancel_bundle();} catch{connection.close();}} // a function that attempts a connection
launcher(destination_list, connection_slot) = {foreach destination in destination_list {spawn(connector(destination, connection_slot); sleep();}} // a function that keeps spawning connections until canceled
start_thread_bundle(launcher(destination_list, connection_slot));
// we are guaranteed to have exactly one good connection and a dead thread bundle
Not sure if your implementation is similar.