kopia lustrzana https://github.com/OpenRTX/OpenRTX
Added the 'sleepUntil' API function to delays interface, allowing to put a thread in sleeping state until a certain absolute timepoint is reached
rodzic
42569af38a
commit
3a288769ba
|
@ -48,6 +48,13 @@ void delayMs(unsigned int mseconds);
|
||||||
*/
|
*/
|
||||||
void sleepFor(unsigned int seconds, 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.
|
* Get the current value of the system tick.
|
||||||
* @return current system tick value.
|
* @return current system tick value.
|
||||||
|
|
|
@ -58,6 +58,11 @@ void sleepFor(unsigned int seconds, unsigned int mseconds)
|
||||||
miosix::Thread::sleep(time);
|
miosix::Thread::sleep(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sleepUntil(long long timestamp)
|
||||||
|
{
|
||||||
|
miosix::Thread::sleepUntil(timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
long long getTick()
|
long long getTick()
|
||||||
{
|
{
|
||||||
return miosix::getTick();
|
return miosix::getTick();
|
||||||
|
|
|
@ -58,6 +58,11 @@ void sleepFor(unsigned int seconds, unsigned int mseconds)
|
||||||
miosix::Thread::sleep(time);
|
miosix::Thread::sleep(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sleepUntil(long long timestamp)
|
||||||
|
{
|
||||||
|
miosix::Thread::sleepUntil(timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
long long getTick()
|
long long getTick()
|
||||||
{
|
{
|
||||||
return miosix::getTick();
|
return miosix::getTick();
|
||||||
|
|
|
@ -40,6 +40,13 @@ void sleepFor(unsigned int seconds, unsigned int mseconds)
|
||||||
delayMs(time);
|
delayMs(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sleepUntil(long long timestamp)
|
||||||
|
{
|
||||||
|
long long delta = timestamp - getTick();
|
||||||
|
if(delta <= 0) return;
|
||||||
|
delayMs(delta);
|
||||||
|
}
|
||||||
|
|
||||||
long long getTick()
|
long long getTick()
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
|
Ładowanie…
Reference in New Issue