4 ms·
Can someone explain how this works please? How does it prevent this from saturating the CPU? while (1) { neco_sleep(NECO_SECOND*2); printf(
by burntcaramel 3y ago
Can someone explain how this works please? How does it prevent this from saturating the CPU?
while (1) {
neco_sleep(NECO_SECOND*2);
printf("tock\n");
}
- swatcoder 3y agoI encourage you to dig through the source. There's not that much. Either this is a library you might use, so you should obviously review the code before you include it in your own work, or this is something that intrigued you, so you'll find clever ideas by digging into its implementation. Here, neco_sleep eventually calls a function that tells the coroutine scheduler to pause the current (calling) and resume the next eligible coroutine in its collection.