source: doc/papers/concurrency/examples/Pingpong.py@ 5b993e0

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 5b993e0 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
RevLine 
[17c6c1c3]1def Scheduler
2try:
3 yield from ping();
4 yield from pong();
5except StopIteration:
6 print( "Scheduler stop" )
7
8
9def pong():
10 print( "pong" )
11for i in range( 10 ):
12
13 yield from ping()
14 print( "stop pong" )
15
16def ping():
17 global i
18 print( "ping" )
19 i += 1
20 if i < 5:
21 yield from pong()
22 print( "stop ping" )
23
24p = ping()
25try:
26 next( p )
27except 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.