Delay = Sleep?

BlitzMax Forums/BlitzMax Beginners Area/Delay = Sleep?

Casaber(Posted 2015) [#1]
Is there a proper OS sleep for BlitzMAX?

How would you sleep on Linux OSx and Windows?

Delay 10 ' would this be a correct sleep to save resources?


xlsior(Posted 2015) [#2]
Yes -- Delay will halt the program and return all available CPU power back to the OS


Kryzon(Posted 2015) [#3]
Delay is a cross-platform function that sleeps the thread in which it's called.
Usually you have a single-threaded program and that's fine, but Delay will also work on other threads of your program.

But if you want to elegantly stall a child thread for an unknown amount of time, instead of calling something like Delay 100 repeatedly, you can use a mutex with WaitMutex for that. Same side effect of the child thread sleeping until you release the mutex.

Internally, Delay wraps the respective sleep command for the OS (Sleep from the Windows API, for example).
https://github.com/maxmods/brl.mod/blob/21e9497433a4aadc3538062dd6181976204824ab/blitz.mod/blitz_app.c#L110


Casaber(Posted 2015) [#4]
Great ! thanks :) good stuff.