code / tomo-coroutines

Lines715 C545 Assembly92 Tomo47 Markdown31
(31 lines)

Tomo Coroutine Library

This is a coroutine library for Tomo built on top of a modified version of libaco.

Example Usage

# modules.ini
[coroutines]
version=v1.0
git=https://github.com/bruce-hill/tomo-coroutines
use coroutines

func main()
    co := Coroutine(func()
        say("I'm in the coroutine!")
        yield()
        say("I'm back in the coroutine!")
    )
    >> co
    say("I'm in the main func")
    >> co.resume()
    say("I'm back in the main func")
    >> co.resume()
    say("I'm back in the main func again")
    >> co.resume()
1 # Tomo Coroutine Library
3 This is a coroutine library for [Tomo](https://tomo.bruce-hill.com) built on
4 top of a modified version of [libaco](https://libaco.org).
6 ## Example Usage
8 ```ini
9 # modules.ini
10 [coroutines]
11 version=v1.0
12 git=https://github.com/bruce-hill/tomo-coroutines
13 ```
15 ```tomo
16 use coroutines
18 func main()
19 co := Coroutine(func()
20 say("I'm in the coroutine!")
21 yield()
22 say("I'm back in the coroutine!")
24 >> co
25 say("I'm in the main func")
26 >> co.resume()
27 say("I'm back in the main func")
28 >> co.resume()
29 say("I'm back in the main func again")
30 >> co.resume()
31 ```