Public Member Functions | Public Attributes | Protected Attributes | Private Attributes

hsm_TimedList Class Reference
[Classes for managing object list]

#include <hsm_TimedList.h>

Inheritance diagram for hsm_TimedList:
Inheritance graph
[legend]
Collaboration diagram for hsm_TimedList:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 hsm_TimedList (bool &a_running, ivd_Time32_t a_waitTime)
virtual ~hsm_TimedList ()
virtual void TaskTime ()=0
 method that is ivoked when time expired
virtual void Run (void *arg)
 Dirty list thread run method.
void Shutdown ()
hsm_FHtimed_li Append (hsm_FileHeader *a_fh_p)
 Over written method from FHlist Add FH to the end of the list and set wakeUpTime reference from FH.
void SpliceToEnd (hsm_FHtimed_li &a_pos)
 Move FH to the end of the list and reset wakeUpTime referenfe from FH.
void SpliceToEndNoLock (hsm_FHtimed_li &a_pos)
void Remove (hsm_FHtimed_li &a_pos)
ivd_Time32_t WakeUpTime ()
 calculate the wakeup time, current + wait time
ivd_Time32_t GetLeastWaitTime ()
 to reconfig wait time element will wait on list waitTime +- one quoter
void Reconfigure (ivd_Time32_t a_CfgMFAge)

Public Attributes

 log_CLASSID_m

Protected Attributes

ivd_Time32_t m_quaterTime
ivd_Time32_t m_waitTime
cmn_Mutex m_timedList_x
bool m_goDown

Private Attributes

bool & m_running
 outside variable that set when thread is down
cmn_Mutex m_thread_x
cmn_Condition m_thread_c

Detailed Description

Definition at line 67 of file hsm_TimedList.h.


Constructor & Destructor Documentation

hsm_TimedList::hsm_TimedList ( bool &  a_running,
ivd_Time32_t  a_waitTime 
)

Definition at line 77 of file hsm_TimedList.cpp.

References log_FUNC_m.

    :
    m_quaterTime(a_waitTime >> 2),
    m_waitTime(a_waitTime), // quater more 
    m_running(a_running),
    m_goDown(false),
    m_thread_c(&m_thread_x)
{
    log_FUNC_m(hsm_TimedList);
}

hsm_TimedList::~hsm_TimedList (  )  [virtual]

Definition at line 92 of file hsm_TimedList.cpp.

References log_FUNC_m, and m_goDown.


Member Function Documentation

hsm_FHtimed_li hsm_TimedList::Append ( hsm_FileHeader a_fh_p  ) 

Over written method from FHlist Add FH to the end of the list and set wakeUpTime reference from FH.

Definition at line 99 of file hsm_TimedList.cpp.

References dbg_DETAIL, hsm_FileHeader::GetFName(), hsm_FileHeader::GetRef(), hsm_FileHeader::IncrRef(), log_DBG_m, log_FUNC_m, m_timedList_x, cmn_Time::Time2hms(), and WakeUpTime().

Referenced by hsm_FileHeader::DecMemberRef(), and hsm_ListPos::ObjChgGoToDirty().

                                                           {
    log_FUNC_m(Append);
    a_fh_p->IncrRef();    
    cmn_MutexLock l(m_timedList_x);
    cmn_Time removeTime(WakeUpTime(), 0);
    log_DBG_m(dbg_DETAIL, " File " << a_fh_p->GetFName() 
                       << " will be removed at " << removeTime.Time2hms()
                       << " ref " << a_fh_p->GetRef());
    return insert(end(), hsm_TimeListElem(a_fh_p, WakeUpTime()));
}

Here is the call graph for this function:

Here is the caller graph for this function:

ivd_Time32_t hsm_TimedList::GetLeastWaitTime (  )  [inline]

to reconfig wait time element will wait on list waitTime +- one quoter

Definition at line 135 of file hsm_TimedList.h.

References m_quaterTime, m_waitTime, and NULL.

Referenced by hsm_FileHeader::InodeChgGoToDirty().

                                    {
        return time(NULL) + m_waitTime - m_quaterTime;

    };

Here is the caller graph for this function:

void hsm_TimedList::Reconfigure ( ivd_Time32_t  a_CfgMFAge  ) 

Reimplemented in hsm_FHdirty.

Definition at line 210 of file hsm_TimedList.cpp.

References m_quaterTime, and m_waitTime.

                                                      {

    m_quaterTime = a_CfgMFAge >> 2;
    m_waitTime   = a_CfgMFAge;
}

void hsm_TimedList::Remove ( hsm_FHtimed_li a_pos  ) 

Definition at line 132 of file hsm_TimedList.cpp.

References dbg_DETAIL, log_DBG_m, log_FUNC_m, and m_timedList_x.

Referenced by hsm_FileHeader::IncMemberRef(), hsm_ListPos::RemoveFromList(), and hsm_DirWaitList::TaskTime().

                                               {
    log_FUNC_m(Remove);

    log_DBG_m(dbg_DETAIL, " File " << (*a_pos).m_fh_p->GetFName() << " is removed.");
    (*a_pos).m_fh_p->DecrRef();    
    cmn_MutexLock l(m_timedList_x);
    erase(a_pos);
}

Here is the caller graph for this function:

void hsm_TimedList::Run ( void *  arg  )  [virtual]

Dirty list thread run method.

Reimplemented from cmn_Thread.

Definition at line 148 of file hsm_TimedList.cpp.

References dbg_DETAIL, dbg_NORM, errno, cmn_Mutex::Lock(), log_DBG_m, log_FUNC_m, m_goDown, m_running, m_thread_c, m_thread_x, m_timedList_x, m_waitTime, size, TaskTime(), cmn_Time::Time2hms(), cmn_Condition::TimedWait(), cmn_Mutex::Unlock(), and WakeUpTime().

                                {
    log_FUNC_m(Run);
    m_running = true;
    log_DBG_m(dbg_NORM, "TimedList is starting up. Wait time is " << m_waitTime << " seconds.");
    while (true) {

        ivd_Time32_t timeWakeUp;

        m_timedList_x.Lock();
        UInt32_t siz = size();
        if (siz == 0) {  // if no elements are in list then wait whole min age time
            m_timedList_x.Unlock();
            timeWakeUp = WakeUpTime();
        }
        else { // else wait as long as first element need to be on list.
            timeWakeUp = (begin())->m_wakeUpTime;
            m_timedList_x.Unlock();
        }

        cmn_Time cmntimewakeup(timeWakeUp, 0);
        log_DBG_m(dbg_DETAIL, "Timed list will wake up at " << cmntimewakeup.Time2hms() <<
            "  has " << siz << " elements." ); //<< " Time set by FH " << inode);
    
        {
            cmn_MutexLock l(m_thread_x);
            if (m_goDown) {
                break;
            }
            m_thread_c.TimedWait(timeWakeUp);
        }
        
        try {
            if (m_goDown) {
                break;
            }
            else {
                TaskTime();    
            }
        }
        catch (...) {
            log_DBG_m(dbg_DETAIL, "TaskTime method go down after thrown ERROR. errno = " << errno );
            break;
        }
    }
    log_DBG_m(dbg_NORM, "TimedList IS_DOWN. Wait time was " << m_waitTime << " seconds.");
    m_running = false;
}

Here is the call graph for this function:

void hsm_TimedList::Shutdown (  ) 

Definition at line 198 of file hsm_TimedList.cpp.

References cmn_Condition::Broadcast(), log_FUNC_m, m_goDown, m_thread_c, and m_thread_x.

Referenced by hsm_Containers::Stop().

Here is the call graph for this function:

Here is the caller graph for this function:

void hsm_TimedList::SpliceToEnd ( hsm_FHtimed_li a_pos  ) 

Move FH to the end of the list and reset wakeUpTime referenfe from FH.

Definition at line 112 of file hsm_TimedList.cpp.

References log_FUNC_m, m_timedList_x, and SpliceToEndNoLock().

Referenced by hsm_FileHeader::DecMemberRef(), and hsm_ListPos::ObjChgGoToDirty().

Here is the call graph for this function:

Here is the caller graph for this function:

void hsm_TimedList::SpliceToEndNoLock ( hsm_FHtimed_li a_pos  ) 

Definition at line 121 of file hsm_TimedList.cpp.

References dbg_DETAIL, log_DBG_m, log_FUNC_m, cmn_Time::Time2hms(), and WakeUpTime().

Referenced by SpliceToEnd(), and hsm_DirWaitList::TaskTime().

                                                            {
    log_FUNC_m(SpliceToEndNoLock);

    a_pos->m_wakeUpTime = WakeUpTime();
    cmn_Time removeTime(a_pos->m_wakeUpTime, 0);
    log_DBG_m(dbg_DETAIL, " File " << (*a_pos).m_fh_p->GetFName() << " is reordered and will be removed at " << removeTime.Time2hms());
    splice(end(), *this, a_pos);
}

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void hsm_TimedList::TaskTime (  )  [pure virtual]

method that is ivoked when time expired

Implemented in hsm_DirWaitList, and hsm_FHdirty.

Referenced by Run().

Here is the caller graph for this function:

ivd_Time32_t hsm_TimedList::WakeUpTime (  )  [inline]

calculate the wakeup time, current + wait time

Definition at line 122 of file hsm_TimedList.h.

References m_waitTime, and NULL.

Referenced by Append(), Run(), SpliceToEndNoLock(), and hsm_FHdirty::TaskTime().

                                     {
        return time(NULL) + m_waitTime; // quater more
    };

Here is the caller graph for this function:


Member Data Documentation

Reimplemented from cmn_Thread.

Reimplemented in hsm_DirWaitList, and hsm_FHdirty.

Definition at line 92 of file hsm_TimedList.h.

bool hsm_TimedList::m_goDown [protected]
bool& hsm_TimedList::m_running [private]

outside variable that set when thread is down

Definition at line 83 of file hsm_TimedList.h.

Referenced by Run().

Definition at line 89 of file hsm_TimedList.h.

Referenced by Run(), and Shutdown().

Definition at line 88 of file hsm_TimedList.h.

Referenced by Run(), and Shutdown().


The documentation for this class was generated from the following files: