1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-29 16:23:09 +00:00

Better document some threads functions

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba 2010-10-12 09:06:33 +02:00
parent 083ed1ce94
commit 7c7a77698a

View file

@ -2463,13 +2463,11 @@ namespace {
void ThreadsManager::exit_threads() { void ThreadsManager::exit_threads() {
ActiveThreads = MAX_THREADS; // HACK ActiveThreads = MAX_THREADS; // Wake up all the threads
AllThreadsShouldSleep = true; // HACK AllThreadsShouldExit = true; // Let the woken up threads to exit idle_loop()
AllThreadsShouldSleep = true; // Avoid an assert in wake_sleeping_threads()
wake_sleeping_threads(); wake_sleeping_threads();
// This makes the threads to exit idle_loop()
AllThreadsShouldExit = true;
// Wait for thread termination // Wait for thread termination
for (int i = 1; i < MAX_THREADS; i++) for (int i = 1; i < MAX_THREADS; i++)
while (threads[i].state != THREAD_TERMINATED) {} while (threads[i].state != THREAD_TERMINATED) {}
@ -2492,9 +2490,9 @@ namespace {
assert(threadID >= 0 && threadID < ActiveThreads); assert(threadID >= 0 && threadID < ActiveThreads);
SplitPoint* sp; SplitPoint* sp = threads[threadID].splitPoint;
for (sp = threads[threadID].splitPoint; sp && !sp->stopRequest; sp = sp->parent) {} for ( ; sp && !sp->stopRequest; sp = sp->parent) {}
return sp != NULL; return sp != NULL;
} }
@ -2519,12 +2517,9 @@ namespace {
// Make a local copy to be sure doesn't change under our feet // Make a local copy to be sure doesn't change under our feet
int localActiveSplitPoints = threads[slave].activeSplitPoints; int localActiveSplitPoints = threads[slave].activeSplitPoints;
if (localActiveSplitPoints == 0) // No active split points means that the thread is available as
// No active split points means that the thread is available as // a slave for any other thread.
// a slave for any other thread. if (localActiveSplitPoints == 0 || ActiveThreads == 2)
return true;
if (ActiveThreads == 2)
return true; return true;
// Apply the "helpful master" concept if possible. Use localActiveSplitPoints // Apply the "helpful master" concept if possible. Use localActiveSplitPoints