source: doc/papers/concurrency/examples/Pingpong.py @ 8a30423

ADTarm-ehast-experimentalcleanup-dtorsenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since 8a30423 was 17c6c1c3, checked in by Peter A. Buhr <pabuhr@…>, 6 years ago

add more paper examples

  • Property mode set to 100644
File size: 465 bytes
Line 
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.