Skip to content

Commit

Permalink
[core] Minor renaming to m_ullSchedTime_tk
Browse files Browse the repository at this point in the history
from m_ullSchedTime. And names of some other variables as well.
  • Loading branch information
maxsharabayko authored and rndi committed Nov 5, 2019
1 parent 372b078 commit 2b34c21
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
20 changes: 10 additions & 10 deletions srtcore/common.cpp
Expand Up @@ -90,7 +90,7 @@ pthread_mutex_t CTimer::m_EventLock = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t CTimer::m_EventCond = PTHREAD_COND_INITIALIZER;

CTimer::CTimer():
m_ullSchedTime(),
m_ullSchedTime_tk(),
m_TickCond(),
m_TickLock()
{
Expand Down Expand Up @@ -180,19 +180,19 @@ uint64_t CTimer::getCPUFrequency()
return s_ullCPUFrequency;
}

void CTimer::sleep(uint64_t interval)
void CTimer::sleep(uint64_t interval_tk)
{
uint64_t t;
rdtsc(t);

// sleep next "interval" time
sleepto(t + interval);
sleepto(t + interval_tk);
}

void CTimer::sleepto(uint64_t nexttime)
void CTimer::sleepto(uint64_t nexttime_tk)
{
// Use class member such that the method can be interrupted by others
m_ullSchedTime = nexttime;
m_ullSchedTime_tk = nexttime_tk;

uint64_t t;
rdtsc(t);
Expand All @@ -205,16 +205,16 @@ void CTimer::sleepto(uint64_t nexttime)
#endif
#endif

while (t < m_ullSchedTime)
while (t < m_ullSchedTime_tk)
{
#if USE_BUSY_WAITING
uint64_t wait_us = (m_ullSchedTime - t) / s_ullCPUFrequency;
uint64_t wait_us = (m_ullSchedTime_tk - t) / s_ullCPUFrequency;
if (wait_us > threshold)
wait_us -= threshold;
if (wait_us < threshold)
break;
#else
const uint64_t wait_us = (m_ullSchedTime - t) / getCPUFrequency();
const uint64_t wait_us = (m_ullSchedTime_tk - t) / getCPUFrequency();
if (wait_us == 0)
break;
#endif
Expand All @@ -236,7 +236,7 @@ void CTimer::sleepto(uint64_t nexttime)
}

#if USE_BUSY_WAITING
while (t < m_ullSchedTime)
while (t < m_ullSchedTime_tk)
{
#ifdef IA32
__asm__ volatile ("pause; rep; nop; nop; nop; nop; nop;");
Expand All @@ -260,7 +260,7 @@ void CTimer::sleepto(uint64_t nexttime)
void CTimer::interrupt()
{
// schedule the sleepto time to the current CCs, so that it will stop
rdtsc(m_ullSchedTime);
rdtsc(m_ullSchedTime_tk);
tick();
}

Expand Down
14 changes: 7 additions & 7 deletions srtcore/common.h
Expand Up @@ -443,15 +443,15 @@ class CTimer

public:

/// Sleep for "interval" CCs.
/// @param [in] interval CCs to sleep.
/// Sleep for "interval_tk" CCs.
/// @param [in] interval_tk CCs to sleep.

void sleep(uint64_t interval);
void sleep(uint64_t interval_tk);

/// Seelp until CC "nexttime".
/// @param [in] nexttime next time the caller is waken up.
/// Seelp until CC "nexttime_tk".
/// @param [in] nexttime_tk next time the caller is waken up.

void sleepto(uint64_t nexttime);
void sleepto(uint64_t nexttime_tk);

/// Stop the sleep() or sleepto() methods.

Expand Down Expand Up @@ -508,7 +508,7 @@ class CTimer
uint64_t getTimeInMicroSec();

private:
uint64_t m_ullSchedTime; // next schedulled time
uint64_t m_ullSchedTime_tk; // next schedulled time

pthread_cond_t m_TickCond;
pthread_mutex_t m_TickLock;
Expand Down

0 comments on commit 2b34c21

Please sign in to comment.