#include <ProcessList.h>
Public Member Functions | |
| ProcessList () | |
| ~ProcessList () | |
| void | AddProcess (pcce::tIProcessPtr process) |
| void | ExecuteProcesses (tMillisecond timeDelta, tMillisecond maxTime) |
| void | ExecuteAllProcesses (tMillisecond timeDelta) |
| void | ExecuteOneProcess (tMillisecond timeDelta) |
| unsigned int | GetProcessCount () |
Private Member Functions | |
| void | DoHandleCurrentItem (tMillisecond timeDelta) |
| void | DoDeleteCurrentItem () |
Private Attributes | |
| ProcessListItem * | mCurrent |
| ProcessListItem * | mPrevious |
| ProcessListItem * | mLast |
| unsigned int | mCount |
Classes | |
| class | ProcessListItem |
Definition at line 43 of file ProcessList.h.
| ProcessList::ProcessList | ( | ) |
| ProcessList::~ProcessList | ( | ) |
Definition at line 52 of file ProcessList.cpp.
References mCurrent, pcce::ProcessList::ProcessListItem::mNext, and mPrevious.
00052 { 00053 if (mCurrent != NULL) { 00054 ProcessListItem* item; 00055 00056 mPrevious->mNext = NULL; 00057 mPrevious = NULL; 00058 00059 while (mCurrent != NULL) { 00060 item = mCurrent; 00061 mCurrent = mCurrent->mNext; 00062 delete item; 00063 } 00064 } 00065 }
| void ProcessList::AddProcess | ( | pcce::tIProcessPtr | process | ) |
Definition at line 67 of file ProcessList.cpp.
References mCount, mCurrent, pcce::ProcessList::ProcessListItem::mData, pcce::ProcessList::ProcessListItem::mNext, mPrevious, and PCCE_CHECK.
Referenced by DoDeleteCurrentItem().
00067 { 00068 process->UnKill(); 00069 00070 ProcessListItem* item = new ProcessListItem(); 00071 item->mData = process; 00072 if (mCurrent == NULL) { 00073 PCCE_CHECK(mCount == 0, "Count is not 0"); 00074 PCCE_CHECK(mPrevious == NULL, "Previous is not NULL"); 00075 mCurrent = item; 00076 mPrevious = item; 00077 } else { 00078 PCCE_CHECK(mPrevious->mNext == mCurrent, "Previous's next is not current"); 00079 } 00080 00081 mPrevious->mNext = item; 00082 item->mNext = mCurrent; 00083 mPrevious = item; 00084 00085 mCount++; 00086 }
| void ProcessList::ExecuteProcesses | ( | tMillisecond | timeDelta, | |
| tMillisecond | maxTime | |||
| ) |
Definition at line 88 of file ProcessList.cpp.
References DoHandleCurrentItem(), pcce::GetTimeSinceStart(), mCurrent, mLast, mPrevious, and PCCE_CHECK.
00088 { 00089 tMillisecond currentTime, endTime; 00090 bool done = false; 00091 00092 PCCE_CHECK(maxTime > 0, "maxTime must be greater than 0"); 00093 00094 if (mCurrent == NULL) { 00095 return; 00096 } 00097 00098 PCCE_CHECK(mLast == NULL, "mLast is not NULL"); 00099 mLast = mPrevious; 00100 00101 currentTime = GetTimeSinceStart(); 00102 endTime = currentTime + maxTime; 00103 00104 while ((!done) && (mCurrent != NULL) && (currentTime < maxTime)) { 00105 if (mCurrent == mLast) { 00106 done = true; 00107 } 00108 DoHandleCurrentItem(timeDelta); 00109 currentTime = GetTimeSinceStart(); 00110 } 00111 00112 mLast = NULL; 00113 }
| void ProcessList::ExecuteAllProcesses | ( | tMillisecond | timeDelta | ) |
Definition at line 115 of file ProcessList.cpp.
References DoHandleCurrentItem(), mCurrent, mLast, mPrevious, and PCCE_CHECK.
00115 { 00116 bool done = false; 00117 00118 if (mCurrent == NULL) { 00119 return; 00120 } 00121 00122 PCCE_CHECK(mLast == NULL, "mLast is not NULL"); 00123 mLast = mPrevious; 00124 00125 while ((!done) && (mCurrent != NULL)) { 00126 if (mCurrent == mLast) { 00127 done = true; 00128 } 00129 DoHandleCurrentItem(timeDelta); 00130 } 00131 00132 mLast = NULL; 00133 }
| void ProcessList::ExecuteOneProcess | ( | tMillisecond | timeDelta | ) |
Definition at line 135 of file ProcessList.cpp.
References DoHandleCurrentItem(), and mCurrent.
00135 { 00136 if (mCurrent == NULL) { 00137 return; 00138 } 00139 DoHandleCurrentItem(timeDelta); 00140 }
| unsigned int ProcessList::GetProcessCount | ( | ) |
Definition at line 142 of file ProcessList.cpp.
References mCount.
00142 { 00143 return mCount; 00144 }
| void ProcessList::DoHandleCurrentItem | ( | tMillisecond | timeDelta | ) | [private] |
Definition at line 146 of file ProcessList.cpp.
References DoDeleteCurrentItem(), mCurrent, pcce::ProcessList::ProcessListItem::mData, pcce::ProcessList::ProcessListItem::mNext, mPrevious, and PCCE_CHECK.
Referenced by ExecuteAllProcesses(), ExecuteOneProcess(), and ExecuteProcesses().
00146 { 00147 PCCE_CHECK(mCurrent != NULL, "Current is NULL"); 00148 tIProcessPtr data = mCurrent->mData; 00149 if (data->IsKilled()) { 00150 DoDeleteCurrentItem(); 00151 } else { 00152 data->vUpdate(timeDelta); 00153 if (data->IsKilled()) { 00154 DoDeleteCurrentItem(); 00155 } else { 00156 mPrevious = mCurrent; 00157 mCurrent = mCurrent->mNext; 00158 } 00159 } 00160 }
| void ProcessList::DoDeleteCurrentItem | ( | ) | [private] |
Definition at line 162 of file ProcessList.cpp.
References AddProcess(), mCount, mCurrent, pcce::ProcessList::ProcessListItem::mData, pcce::ProcessList::ProcessListItem::mNext, mPrevious, and PCCE_CHECK.
Referenced by DoHandleCurrentItem().
00162 { 00163 PCCE_CHECK(mCurrent != NULL, "Current is NULL"); 00164 00165 ProcessListItem* item = mCurrent; 00166 tIProcessPtr next = item->mData->GetNext(); 00167 00168 if (mCount == 1) { 00169 mCurrent = NULL; 00170 mPrevious = NULL; 00171 } else { 00172 mCurrent = mCurrent->mNext; 00173 mPrevious->mNext = mCurrent; 00174 } 00175 delete item; 00176 mCount--; 00177 00178 if (next) { 00179 AddProcess(next); 00180 } 00181 }
ProcessListItem* pcce::ProcessList::mCurrent [private] |
Definition at line 57 of file ProcessList.h.
Referenced by AddProcess(), DoDeleteCurrentItem(), DoHandleCurrentItem(), ExecuteAllProcesses(), ExecuteOneProcess(), ExecuteProcesses(), and ~ProcessList().
ProcessListItem* pcce::ProcessList::mPrevious [private] |
Definition at line 60 of file ProcessList.h.
Referenced by AddProcess(), DoDeleteCurrentItem(), DoHandleCurrentItem(), ExecuteAllProcesses(), ExecuteProcesses(), and ~ProcessList().
ProcessListItem* pcce::ProcessList::mLast [private] |
Definition at line 61 of file ProcessList.h.
Referenced by ExecuteAllProcesses(), and ExecuteProcesses().
unsigned int pcce::ProcessList::mCount [private] |
Definition at line 63 of file ProcessList.h.
Referenced by AddProcess(), DoDeleteCurrentItem(), and GetProcessCount().
1.5.5