ADT
arm-eh
ast-experimental
cleanup-dtors
enum
forall-pointer-decay
jacob/cs343-translation
jenkins-sandbox
new-ast
new-ast-unique-expr
pthread-emulation
qualifiedEnum
|
Last change
on this file since 1097bb7 was 17c6c1c3, checked in by Peter A. Buhr <pabuhr@…>, 7 years ago |
|
add more paper examples
|
-
Property mode
set to
100644
|
|
File size:
465 bytes
|
| Line | |
|---|
| 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.