Elegant output for multi-threaded haskell

This is a completely theoretical point, but I tried to wrap around this problem. Take for example the client. There is forkIOd for each connection, and one of them wants to exit the whole program (i.e. / exit). How to spread this information on other topics?

This is not a condition, but I assume that the threads are read from their respective threads, which are blocked. Since they stand idle until something is written for them, they cannot interrogate any "done" variable. So my first thought is unless doneposted.

I do not have a solution for any program, so anyone who provides solutions for any language is evaluated, but the real question is how to do this in Haskell.

+3
source share
1 answer

The best way I know is the poison that is implemented by the CHP library.

See an excellent explanation here: http://chplib.wordpress.com/2009/09/30/poison-concurrent-termination/

The above article, by the way, goes through other solutions and explains why they are generally somewhat fragile.

+8
source

Source: https://habr.com/ru/post/1765933/


All Articles