Open suvarchal opened 2 years ago
I noticed this as well. Funnily enough, your correction is incorrect too. It should be like this:
coroutine void worker(void) {
int rc = msleep(now() + (random() % 2000));
if(rc < 0 && errno == ECANCELED) return; /* 4. */
/* 2. */
}
int main(void) {
int cr = go(worker()); /* 1. */
msleep(now() + 1000);
hclose(cr); /* 3. */
return 0;
}
In section
What are the use cases? > Parent coroutine closes child coroutine http://libdill.org/structured-concurrency.html#parent-coroutine-closes-child-coroutine
In the code example shown,i think, does not fit to the description, it was a bit of confusion for me until to realize later it might be a bug in the example. Given example
should be with random deadline in the worker
btw thanks for the wonderful library and well thought examples in tutorial.