ms: Add is_idle() method to GprsMs::Guard

Currently there is no simple way to determine, whether the MS object
protected by a guard will continue to exist after the guard object is
destroyed.

This patch adds a is_idle() method that will return true if the MS
object is just kept by the guard from being idle. In that case, the
MS object would either be deleted or return true for
GprsMs::is_idle() after the guard's destruction, provided that no
TBF attachment took place in between.

Sponsored-by: On-Waves ehf
This commit is contained in:
Jacob Erlbeck 2015-07-13 14:23:32 +02:00
parent 3a10dbd564
commit b2439bbb8a
2 changed files with 10 additions and 0 deletions

View File

@ -62,6 +62,14 @@ GprsMs::Guard::~Guard()
m_ms->unref();
}
bool GprsMs::Guard::is_idle() const
{
if (!m_ms)
return true;
return !m_ms->m_ul_tbf && !m_ms->m_dl_tbf && m_ms->m_ref == 1;
}
void GprsMs::timeout(void *priv_)
{
GprsMs *ms = static_cast<GprsMs *>(priv_);

View File

@ -51,6 +51,8 @@ public:
Guard(GprsMs *ms);
~Guard();
bool is_idle() const;
private:
GprsMs * const m_ms;
};