Øyvind Teig
Øyvind Teig

Reputation: 149

What is "suspension context of a function" in C++

The "Wording for Coroutines" (document C++ P0057R5) by Gor Nishanov, Jens Maurer, Richard Smith and Daveed Vandevoorde, see P0057r5, talks a lot about "suspension context of a function" and points directly to "5.3.8"

Where is this defined?

I am asking because, for a process, some times some code is or should have been required to be or not be at certain places. Like Notify (I think it was) that in Java should have been required to be the last statement ("Java’s Insecure Paralleism" by Per Brinch Hansen (1999)). I wonder if suspension context of a function is at such a place?

Upvotes: 1

Views: 167

Answers (1)

Barry
Barry

Reputation: 303377

In exactly the spot in the paper where it says it's defined:

An await-expression shall appear only in a potentially-evaluated expression within the compound-statement of a function-body outside of a handler (15). In a declaration-statement or in the simple-declaration (if any) of a for-init-statement, an await-expression shall appear only in an initializer of that declaration-statement or simple-declaration. An await-expression shall not appear in a default argument (8.3.6). A context within a function where an await-expression can appear is called a suspension context of the function.

Upvotes: 1

Related Questions