Comments by "Lawrence D’Oliveiro" (@lawrencedoliveiro9104) on "ArjanCodes"
channel.
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
@zacharythatcher7328 Threads are not an alternative to callbacks. Threaded event loops (in fact, threaded everything) were all the rage in the 1990s, until it was realized that they made the code very hard to debug. That’s why we now stick to single-threaded event loops, select(2)/poll(2)/epoll(2) etc. But then, time-consuming tasks required the use of callbacks to maximize responsiveness, until the old technique of coroutines was revived more recently as a way to make such code more readable. This has required language changes, but a lot of languages (Python included) have adopted those changes.
What Arjan is using threads for here, and what I have done with them myself, is to turn blocking calls into non-blocking ones. That’s all. Luckily, in POSIX, “blocking” normally means “thread-blocking”, not “process-blocking”. That’s why we can get away with it. Again, it’s all in the cause of maximizing responsiveness, without getting back into the hell of full-on multithreading.
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1
-
1