Introduce function to sleeping

Actually just refactored a bit of code from the test suite which had
an implementation of cross-platform sleep.
New option for realtime mode

Useful for plugins such as Virus Control which cannot do offline processing.