package my_coroutine
import co "path/to/coro"
import "core:fmt"
message := "this is.."
main :: proc() {
c := co.create(proc(cc: co.Caller) {
for _ in 0..<2 {
fmt.println(message)
co.pass(cc)
}
})co.resume(&c)This is..message = "..a test"
co.resume(&c)..a test// resume returns false when the coroutines done
assert(co.resume(&c) == false)
fmt.println("A resounding success")A resounding successpackage my_coroutine
import co "path/to/coro"
import "core:fmt"
message := "this is.."
main :: proc() {
c := co.create(proc(cc: co.Caller) {
for _ in 0..<2 {
fmt.println(message)
co.pass(cc)
}
})
co.resume(&c)
message = "..a test"
co.resume(&c)
// resume returns false when the coroutines done
assert(co.resume(&c) == false)
fmt.println("A resounding success")
}This is..
..a test
A resounding successcd your-project
git clone https://github.com/Carlyle-Foster/coro.gitimport co "coro"thank u to tsoding's C coroutine library, our distant ancestor.
the ship of theseus has sailed indeed...