12345678910111213141516171819202122232425262728293031323334353637 |
- include "io.alh"
- include "primitives.alh"
- // Placeholder for internal functions
- Element function __input()
- Void function __output(value : Element)
- Element function input():
- while (bool_not(has_input())):
- interruptable_sleep(0.5)
-
- Element inp
- inp = __input()
- return inp!
- Void function output(value : Element):
- __output(value)
- return!
- Element function input_timeout(timeout : Float):
- Float start
- start = time()
- // Do this first, such that we will always get at least the chance to push input in
- if (has_input()):
- return input()!
- // Now just try this again from time to time
- while (time() - start < timeout):
- if (has_input()):
- return input()!
- else:
- // Nothing to do, we should yield...
- interruptable_sleep(0.1)
- return read_root()!
|