29 doneExecuting (
false),
30 maxNumThreads (_maxNumThreads),
32 shutdownRequested (
false),
33 terminateFlag (
false),
34 terminateRequested (
false),
57 threads->PushOnBack (_thread);
64 shutdownRequested =
true;
70 terminateRequested =
true;
81 KKThreadList::iterator idx;
82 for (idx = threads->begin (); idx != threads->end (); ++idx)
103 kkint32 lastNumThreadsRunning = 0;
104 kkint32 lastNumThreadsStopped = 0;
106 bool allTreadsAreShutdown =
false;
108 while (!allTreadsAreShutdown)
110 allTreadsAreShutdown =
true;
114 KKThreadList::iterator idx;
115 for (idx = threads->begin (); idx != threads->end (); ++idx)
131 allTreadsAreShutdown =
false;
137 allTreadsAreShutdown =
false;
143 numMiliSecsWaited = 0;
157 if ((numThreadsRunning != lastNumThreadsRunning) ||
158 (numThreadsStopped != lastNumThreadsStopped)
162 numMiliSecsWaited = 0;
165 if (!allTreadsAreShutdown)
167 if ((miliSecsToWait > 0) && (numMiliSecsWaited > miliSecsToWait))
177 numMiliSecsWaited += 10;
190 KKThreadList::iterator idx;
191 for (idx = threads->begin (); idx != threads->end (); ++idx)
202 AddMsg (
"KKThreadManager::StartThreads");
209 bool allThreadsStarted =
false;
211 while (!allThreadsStarted)
213 allThreadsStarted =
true;
214 KKThreadList::iterator idx;
215 for (idx = threads->begin (); idx != threads->end (); ++idx)
229 bool successfulStart =
false;
231 if (!successfulStart)
233 allThreadsStarted =
false;
240 allThreadsStarted =
false;
245 if (!allThreadsStarted)
257 bool anyProcessorsCrashed =
false;
261 KKThreadList::iterator idx;
262 for (idx = threads->begin (); idx != threads->end (); ++idx)
267 anyProcessorsCrashed =
true;
273 crashed = anyProcessorsCrashed;
275 return anyProcessorsCrashed;
282 bool allThreadsTerminated =
true;
286 KKThreadList::const_iterator idx;
287 for (idx = threads->begin (); idx != threads->end (); ++idx)
292 allThreadsTerminated =
false;
298 return allThreadsTerminated;
311 StartThreads (successful);
318 if (shutdownRequested)
320 shutdownRequested =
false;
325 else if (terminateRequested)
327 terminateRequested =
false;
341 AddMsg (
"One or more processors crashed!!!");
void Start(ThreadPriority _priority, bool &successful)
ThreadStatus Status() const
KKThread(const KKStr &_threadName, KKThreadManagerPtr _threadManager, MsgQueuePtr _msgQueue)
bool AllThreadsTerminated()
void ShutdownProcessing(kkint32 miliSecsToWait)
Shutdown all threads in a orderly way; observing prerequisite ordering.
bool AnyProcessorsCrashed()
unsigned __int32 kkuint32
void osSleep(float numOfSecs)
KKThreadManager(const KKStr &_managerName, kkuint32 _maxNumThreads, MsgQueuePtr _msgQueue)
The base class to be used any thread.
bool OkToShutdown() const
static KKStr Concat(const std::vector< std::string > &values)
Concatenates the list of 'std::string' strings.
void KillAllRunningThreads()
KKThreadList(bool _owner=true)
void TerminateProcessing()
VolConstBool & ShutdownFlag() const
void Kill()
stops the running thread and frees the thread handle
void AddThread(KKThreadPtr _thread)
void ManageThreads(bool &successful)