elizarov
04/11/2017, 5:18 PMrunAsync1
is very expensive for short tasks. You can test by passing an empty task to it and measuring how many per second of those you can do. On the flip side, if your tasks are long, don’t come very often (at most a dozen per second), and don’t actually consume CPU (block on IO call), this might be a good solution.
* runAsync2
is very cheap. You can literally do hundreds of thousands per seconds. However, it only uses n-1 threads (n == # of CPUs), so if your task blocks, then you’ll get no progress after n-1 submitted tasks. On the flip side, if you use suspending/non-blocking code (e.g. you suspend on IO instead of blocking), then you can achieve much better scalability.