arm-ehcleanup-dtorsenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-expr
Last change
on this file since 0087e0e was
17c6c1c,
checked in by Peter A. Buhr <pabuhr@…>, 3 years ago
|
add more paper examples
|
-
Property mode set to
100644
|
File size:
465 bytes
|
Rev | Line | |
---|
[17c6c1c] | 1 | def Scheduler |
---|
| 2 | try: |
---|
| 3 | yield from ping(); |
---|
| 4 | yield from pong(); |
---|
| 5 | except StopIteration: |
---|
| 6 | print( "Scheduler stop" ) |
---|
| 7 | |
---|
| 8 | |
---|
| 9 | def pong(): |
---|
| 10 | print( "pong" ) |
---|
| 11 | for i in range( 10 ): |
---|
| 12 | |
---|
| 13 | yield from ping() |
---|
| 14 | print( "stop pong" ) |
---|
| 15 | |
---|
| 16 | def ping(): |
---|
| 17 | global i |
---|
| 18 | print( "ping" ) |
---|
| 19 | i += 1 |
---|
| 20 | if i < 5: |
---|
| 21 | yield from pong() |
---|
| 22 | print( "stop ping" ) |
---|
| 23 | |
---|
| 24 | p = ping() |
---|
| 25 | try: |
---|
| 26 | next( p ) |
---|
| 27 | except StopIteration: |
---|
| 28 | print( "stop" ) |
---|
| 29 | |
---|
| 30 | # Local Variables: # |
---|
| 31 | # tab-width: 4 # |
---|
| 32 | # compile-command: "python3.5 pingpong.py" # |
---|
| 33 | # End: # |
---|
Note: See
TracBrowser
for help on using the repository browser.