sleeping vs sched_yield
stanislav.blinov at gmail.com
Thu Dec 2 23:48:53 UTC 2021
On Thursday, 2 December 2021 at 23:29:17 UTC, Chris Katko wrote:
> 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
> It seems I can (thanks to the amazing work of D community)
> simply do:
> 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?
Linker doesn't need sched.h. Like H.S.Theoh said, it'll look for
that symbol in libraries you're linking against. sched_yield is
in libc, and by default you do link against that.
> source/app.d(226,16): Error: cannot have parameter of type
> 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