On Saturday, 17 August 2024 at 19:49:04 UTC, Vinod K Chandran wrote:
All I want is a delay function which simulate some work load in current thread.

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.
  • Re: How to find ... monkyyy via Digitalmars-d-learn
    • Re: How to ... Bruce via Digitalmars-d-learn
    • Re: How to ... Ron Tarrant via Digitalmars-d-learn
    • Re: How to ... Renato Athaydes via Digitalmars-d-learn
    • Re: How to ... Lance Bachmeier via Digitalmars-d-learn
    • Re: How to ... Steven Schveighoffer via Digitalmars-d-learn
      • Re: How... Vinod K Chandran via Digitalmars-d-learn
        • Re:... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
          • ... Vinod K Chandran via Digitalmars-d-learn
        • Re:... IchorDev via Digitalmars-d-learn
          • ... Vinod K Chandran via Digitalmars-d-learn
      • Re: How... Ron Tarrant via Digitalmars-d-learn
        • Re:... Renato Athaydes via Digitalmars-d-learn
      • Re: How... Andy Valencia via Digitalmars-d-learn
        • Re:... IchorDev via Digitalmars-d-learn
          • ... Andy Valencia via Digitalmars-d-learn
            • ... IchorDev via Digitalmars-d-learn

Reply via email to