about summary refs log tree commit diff stats
path: root/html/subx/070new-stream.subx.html
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2023-12-07 21:48:47 -0800
committerKartik K. Agaram <vc@akkartik.com>2023-12-07 21:48:47 -0800
commitae4058add3c2002b90f171a1ace40bf21118103e (patch)
treed7bfb5e655895eb86ba9e239ae245fd65fab00b3 /html/subx/070new-stream.subx.html
parent204589b2ffc8aa16fa2953017eaa6614f7d05eb5 (diff)
downloadmu-ae4058add3c2002b90f171a1ace40bf21118103e.tar.gz
halt until exception when waiting for keyboard hlt
This reduces CPU consumption from 180% to 2% when running Qemu.

Many thanks to Fabian of https://copy.sh for this suggestion.
Diffstat (limited to 'html/subx/070new-stream.subx.html')
0 files changed, 0 insertions, 0 deletions
hut <hut@lavabit.com> 2010-04-18 13:10:40 +0200 Fixed unittests' href='/akspecs/ranger/commit/test/tc_keyapi.py?h=v1.7.1&id=76e9b89a9cb8ea1ecbdd194e62441e447ac958e8'>76e9b89a ^
a666f32b ^








1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41














                                                                       





                                                            
                                                   

                                      
                                                 



                                                                            
                                                   
                                             
                                                     








                                         
# Example program showing that a function call can be 'paused' multiple times,
# creating different continuation values.
#
# To run:
#   $ git clone https://github.com/akkartik/mu
#   $ cd mu
#   $ ./mu continuation3.mu
#
# Expected output:
#   caller 0
#   callee 0
#   caller 1
#   callee 1
#   caller 2
#   callee 2

def main [
  local-scope
  $print [caller 0] 10/newline
  k:continuation <- call-with-continuation-mark 100/mark, f
  $print [caller 1] 10/newline
  k <- call k
  $print [caller 2] 10/newline
  call k
]

def f [
  local-scope
  $print [callee 0] 10/newline
  return-continuation-until-mark 100/mark
  $print [callee 1] 10/newline
  return-continuation-until-mark 100/mark
  $print [callee 2] 10/newline
]