A green thread in our world is not an OS thread - it is a resumable task, a small step function the scheduler runs a little at a time. Today you define the one type everything else depends on - the status a task hands back each time it is stepped.
Define a Status with the values Ready, Blocked, and Done, and a task whose step reports one of them.
A real green-thread runtime saves and restores machine stacks so a paused thread
can resume exactly where it left off. That is impossible to test with exact values
and different in every language, so we do the honest teaching version: a green
thread is a resumable task, and a task is just a step function. Each time
the scheduler runs it, the function does a little work and returns a Status
saying what to do next - Ready (I yielded, run me again), Blocked (I am parked,
leave me alone), or Done (I finished).
That one return value is the entire contract between a task and the scheduler, so it is where the project starts. Today is deliberately tiny: define the three statuses and a task that returns one when stepped. Every later lesson - yielding, blocking, sleeping, channels - is a task returning one of these three values at the right moment.
// the whole runtime is driven by this one return valuetype Status intconst (Ready Status = iota // did a unit of work; run me againBlocked // parked on a resource; do not run meDone // finished)// a task is just a step function that returns where it standstype Task struct{ step func() Status }