experimental_continuation3.carbon 415 B

123456789101112131415161718
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. // Test pausing a continuation with `__await` and restarting it with
  5. // `__run`.
  6. fn main() -> Int {
  7. var Int x = 0;
  8. __continuation k {
  9. x = x + 1;
  10. __await;
  11. x = x + 2;
  12. }
  13. __run k;
  14. __run k;
  15. return x;
  16. }