I do think we should have some kind of async gating primitive in the concurrency library with built-in priority inversion avoidance, and we should encourage people to use that rather than continuations directly. The design challenge with such a primitive is all around how to reasonably give access to its internal data structures. The primitive inherently needs to track things like who's waiting at the gate and who's currently inside, and a lot of the utilities you'd want to define using the primitive (like a non-reentrant async lock) could take advantage of that information directly rather than having to duplicate it. But while that information never needs to change concurrently — we can expect uses of the primitive to be externally synchronized — it does need to be read concurrently when task priorities change. Anyway, it's a whole separate discussion.
5 Likes