experimental_continuation3.carbon 454 B

1234567891011121314151617181920
  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. package ExecutableSemanticsTest api;
  5. // Test pausing a continuation with `__await` and restarting it with
  6. // `__run`.
  7. fn main() -> i32 {
  8. var x: i32 = 0;
  9. __continuation k {
  10. x = x + 1;
  11. __await;
  12. x = x + 2;
  13. }
  14. __run k;
  15. __run k;
  16. return x;
  17. }