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.


Detailed Description

Definition at line 53 of file hsm_TimedList.h.


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

Constructor & Destructor Documentation

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

Definition at line 63 of file hsm_TimedList.cpp.

References log_FUNC_m.

00066     :
00067     m_quaterTime(a_waitTime >> 2),
00068     m_waitTime(a_waitTime), // quater more 
00069     m_running(a_running),
00070     m_goDown(false),
00071     m_thread_c(&m_thread_x)
00072 {
00073     log_FUNC_m(hsm_TimedList);
00074 }
//============================================================================//

hsm_TimedList::~hsm_TimedList (  )  [virtual]

Definition at line 78 of file hsm_TimedList.cpp.

References log_FUNC_m, and m_goDown.

00078                              {
00079     log_FUNC_m(~hsm_TimedList);
00080     m_goDown = true;
00081 }


Member Function Documentation

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:

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

Dirty list thread run method.

Reimplemented from cmn_Thread.

Definition at line 134 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().

00134                                 {
00135     log_FUNC_m(Run);
00136     m_running = true;
00137     log_DBG_m(dbg_NORM, "TimedList is starting up. Wait time is " << m_waitTime << " seconds.");
00138     while (true) {
00139 
00140         ivd_Time32_t timeWakeUp;
00141 
00142         m_timedList_x.Lock();
00143         UInt32_t siz = size();
00144         if (siz == 0) {  // if no elements are in list then wait whole min age time
00145             m_timedList_x.Unlock();
00146             timeWakeUp = WakeUpTime();
00147         }
00148         else { // else wait as long as first element need to be on list.
00149             timeWakeUp = (begin())->m_wakeUpTime;
00150             m_timedList_x.Unlock();
00151         }
00152 
00153         cmn_Time cmntimewakeup(timeWakeUp, 0);
00154         log_DBG_m(dbg_DETAIL, "Timed list will wake up at " << cmntimewakeup.Time2hms() <<
00155             "  has " << siz << " elements." ); //<< " Time set by FH " << inode);
00156     
00157         {
00158             cmn_MutexLock l(m_thread_x);
00159             if (m_goDown) {
00160                 break;
00161             }
00162             m_thread_c.TimedWait(timeWakeUp);
00163         }
00164         
00165         try {
00166             if (m_goDown) {
00167                 break;
00168             }
00169             else {
00170                 TaskTime();    
00171             }
00172         }
00173         catch (...) {
00174             log_DBG_m(dbg_DETAIL, "TaskTime method go down after thrown ERROR. errno = " << errno );
00175             break;
00176         }
00177     }
00178     log_DBG_m(dbg_NORM, "TimedList IS_DOWN. Wait time was " << m_waitTime << " seconds.");
00179     m_running = false;
00180 }

Here is the call graph for this function:

void hsm_TimedList::Shutdown (  ) 

Definition at line 184 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().

00184                              {
00185     log_FUNC_m(Shutdown);
00186         
00187     cmn_MutexLock l(m_thread_x);
00188     
00189     m_goDown = true;
00190     m_thread_c.Broadcast();
00191 }

Here is the call graph for this function:

Here is the caller graph for this function:

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 85 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().

00085                                                            {
00086     log_FUNC_m(Append);
00087     a_fh_p->IncrRef();    
00088     cmn_MutexLock l(m_timedList_x);
00089     cmn_Time removeTime(WakeUpTime(), 0);
00090     log_DBG_m(dbg_DETAIL, " File " << a_fh_p->GetFName() 
00091                        << " will be removed at " << removeTime.Time2hms()
00092                        << " ref " << a_fh_p->GetRef());
00093     return insert(end(), hsm_TimeListElem(a_fh_p, WakeUpTime()));
00094 }

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 98 of file hsm_TimedList.cpp.

References log_FUNC_m, m_timedList_x, and SpliceToEndNoLock().

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

00098                                                       {
00099     log_FUNC_m(SpliceToEnd);
00100 
00101     cmn_MutexLock l(m_timedList_x);
00102     SpliceToEndNoLock(a_pos);
00103 }

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 107 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().

00107                                                             {
00108     log_FUNC_m(SpliceToEndNoLock);
00109 
00110     a_pos->m_wakeUpTime = WakeUpTime();
00111     cmn_Time removeTime(a_pos->m_wakeUpTime, 0);
00112     log_DBG_m(dbg_DETAIL, " File " << (*a_pos).m_fh_p->GetFName() << " is reordered and will be removed at " << removeTime.Time2hms());
00113     splice(end(), *this, a_pos);
00114 }

Here is the call graph for this function:

Here is the caller graph for this function:

void hsm_TimedList::Remove ( hsm_FHtimed_li a_pos  ) 

Definition at line 118 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().

00118                                                {
00119     log_FUNC_m(Remove);
00120 
00121     log_DBG_m(dbg_DETAIL, " File " << (*a_pos).m_fh_p->GetFName() << " is removed.");
00122     (*a_pos).m_fh_p->DecrRef();    
00123     cmn_MutexLock l(m_timedList_x);
00124     erase(a_pos);
00125 }

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 108 of file hsm_TimedList.h.

References m_waitTime, and NULL.

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

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

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 121 of file hsm_TimedList.h.

References m_quaterTime, m_waitTime, and NULL.

Referenced by hsm_FileHeader::InodeChgGoToDirty().

00121                                     {
00122         return time(NULL) + m_waitTime - m_quaterTime;
00123 
00124     };

Here is the caller graph for this function:

void hsm_TimedList::Reconfigure ( ivd_Time32_t  a_CfgMFAge  ) 

Reimplemented in hsm_FHdirty.

Definition at line 196 of file hsm_TimedList.cpp.

References m_quaterTime, and m_waitTime.

Referenced by hsm_FHdirty::Reconfigure().

00196                                                       {
00197 
00198     m_quaterTime = a_CfgMFAge >> 2;
00199     m_waitTime   = a_CfgMFAge;
00200 }

Here is the caller graph for this function:


Member Data Documentation

bool& hsm_TimedList::m_running [private]

outside variable that set when thread is down

Definition at line 69 of file hsm_TimedList.h.

Referenced by Run().

bool hsm_TimedList::m_goDown [protected]

Definition at line 74 of file hsm_TimedList.h.

Referenced by Run(), and Shutdown().

Definition at line 75 of file hsm_TimedList.h.

Referenced by Run(), and Shutdown().

Reimplemented from cmn_Thread.

Reimplemented in hsm_DirWaitList, and hsm_FHdirty.

Definition at line 78 of file hsm_TimedList.h.


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

Generated on Mon Feb 27 19:29:48 2012 for OPENARCHIVE by  doxygen 1.5.6