in reply to RFC: Proposed module POSIX::Yield

threads::yield is portable across platforms and does much the same thing as your code under Linux.

I tend to use Win32::Sleep $milliseconds; to yield the processor inside poll-type loops, because it allows me to strike a balance between responsivness and threashing the processor to death.

If shed_yield() has application outside of threaded code, perhaps you could offer a patch to the POSIX module?


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: RFC: Proposed module POSIX::Yield
by tirwhan (Abbot) on Dec 02, 2005 at 17:23 UTC

    Thanks, I think I will try with a patch to POSIX and see where that gets me. That is the most logical place to look for it, and even though threads->yield will apparently do the same thing in most cases, users are more likely to recognise they can use POSIX::sched_yield() for processes.


    Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. -- Brian W. Kernighan