How to find the right function in the Phobos library?

Vinod K Chandran kcvinu82 at gmail.com
Sun Aug 18 16:20:06 UTC 2024


On Sunday, 18 August 2024 at 08:39:49 UTC, IchorDev wrote:
>
> As Rikki points out, delay or sleep functions (as the name 
> says) ‘put the thread to sleep’. If you want the thread to be 
> constantly busy, you can use a while loop:
> ```d
> import core.time;
>
> //waste electricity for 1ms:
> const endTime = MonoTime.currTime + 1.msecs;
> while(MonoTime.currTime < endTime){}
> ```
> Note that it’s better to let the thread rest because otherwise 
> the OS might be starved for threads, or the CPU will consume 
> more electricity and could overheat unnecessarily, hindering 
> your program’s performance.
>
Thank you IchorDev for the sample code. Got the idea.




More information about the Digitalmars-d-learn mailing list