Few clarification points:
- By heavy I mean it can block thread, e.g. long running operation
- Yes, of course main point of
suspend
keyword is to mark suspension points, but it also serve as “marker” for caller: this function is compiled to function with continuation (callback) = this function has suspension point = this function may block your thread
l
louiscad
04/01/2018, 5:52 AM
Nope,
suspend
is not a "marker" for things that block threads.
suspend
is solely for allowing suspension points. If you want to have blocking code that can run on arbitrary thread pool, then coroutines are not your solution. "Regular" blocking code is yours, and a custom documented annotation, plus maybe ruling out UI/event loop thread(s) are your best solutions. A good one also is to name your function