sleeping vs sched_yield
Chris Katko
ckatko at gmail.com
Thu Dec 2 23:29:17 UTC 2021
there's:
```d
import core.thread;
Thread.sleep( dur!("msecs")(10) );
```
but what if you want to simply yield all remaining time back to
the time scheduler?
Is there a D std.library accessible version of POSIX sched_yield:
https://man7.org/linux/man-pages/man2/sched_yield.2.html
It seems I can (thanks to the amazing work of D community) simply
do:
```d
extern(C) int sched_yield(void); // #include <sched.h>
```
however, how does the linker know I need <sched.h> and not some
local library, or SDL library, or SDL2.0 library, etc. Shouldn't
I be specifying the library somewhere?
Side side question: The above line fails to compile as-is because
it has (void) instead of ().
```
source/app.d(226,16): Error: cannot have parameter of type `void`
```
Should that be corrected in the compiler? Shouldn't () and (void)
be interchangeable as long as you're not doing void*?
More information about the Digitalmars-d-learn
mailing list