Skip to content

Commit 1a5187b

Browse files
committed
You don't actually need the dead flag.
The dead coroutines are kept track by the dead list.
1 parent f54fa0f commit 1a5187b

File tree

1 file changed

+0
-4
lines changed

1 file changed

+0
-4
lines changed

coroutine.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
typedef struct {
4444
void *rsp;
4545
void *stack_base;
46-
bool dead;
4746
} Context;
4847

4948
typedef struct {
@@ -223,7 +222,6 @@ void coroutine_finish(void)
223222
return;
224223
}
225224

226-
contexts.items[active.items[current]].dead = true;
227225
da_append(&dead, active.items[current]);
228226
da_remove_unordered(&active, current);
229227

@@ -254,8 +252,6 @@ void coroutine_go(void (*f)(void*), void *arg)
254252
size_t id;
255253
if (dead.count > 0) {
256254
id = dead.items[--dead.count];
257-
assert(contexts.items[id].dead);
258-
contexts.items[id].dead = false;
259255
} else {
260256
// TODO: Mark the page at the end of the stack buffer as non-readable, non-writable, non-executable to make stack overflows of coroutines more obvious in the debugger
261257
// This may require employing mmap(2) and mprotect(2) on Linux.

0 commit comments

Comments
 (0)