Added the 'sleepUntil' API function to delays interface, allowing to put a thread in sleeping state until a certain absolute timepoint is reached

pull/87/head
Silvano Seva 2022-06-29 17:51:06 +02:00
rodzic 42569af38a
commit 3a288769ba
4 zmienionych plików z 24 dodań i 0 usunięć

Wyświetl plik

@ -48,6 +48,13 @@ void delayMs(unsigned int mseconds);
*/
void sleepFor(unsigned int seconds, unsigned int mseconds);
/**
* Puts the calling thread in a sleeping state until the system time reaches
* the target value passed as parameter.
* @param timestamp: traget timestamp for the wakeup.
*/
void sleepUntil(long long timestamp);
/**
* Get the current value of the system tick.
* @return current system tick value.

Wyświetl plik

@ -58,6 +58,11 @@ void sleepFor(unsigned int seconds, unsigned int mseconds)
miosix::Thread::sleep(time);
}
void sleepUntil(long long timestamp)
{
miosix::Thread::sleepUntil(timestamp);
}
long long getTick()
{
return miosix::getTick();

Wyświetl plik

@ -58,6 +58,11 @@ void sleepFor(unsigned int seconds, unsigned int mseconds)
miosix::Thread::sleep(time);
}
void sleepUntil(long long timestamp)
{
miosix::Thread::sleepUntil(timestamp);
}
long long getTick()
{
return miosix::getTick();

Wyświetl plik

@ -40,6 +40,13 @@ void sleepFor(unsigned int seconds, unsigned int mseconds)
delayMs(time);
}
void sleepUntil(long long timestamp)
{
long long delta = timestamp - getTick();
if(delta <= 0) return;
delayMs(delta);
}
long long getTick()
{
/*