ARGoS
3
A parallel, multi-engine simulator for swarm robotics
|
#include "space_multi_thread_balance_length.h"
#include <argos3/core/simulator/simulator.h>
#include <argos3/core/utility/profiler/profiler.h>
#include <cstdio>
Go to the source code of this file.
Classes | |
struct | argos::SCleanupThreadData |
Namespaces | |
namespace | argos |
The namespace containing all the ARGoS related code. | |
Defines | |
#define | MAIN_START_PHASE(PHASE) |
#define | MAIN_WAIT_FOR_END_OF(PHASE) |
#define | THREAD_WAIT_FOR_START_OF(PHASE) |
#define | THREAD_DISPATCH_TASK(TASKVEC) |
#define | THREAD_PERFORM_TASK(PHASE, SNIPPET) |
Functions | |
void * | argos::LaunchThreadBalanceLength (void *p_data) |
#define MAIN_START_PHASE | ( | PHASE | ) |
pthread_mutex_lock(&m_tStart ## PHASE ## PhaseMutex); \ m_un ## PHASE ## PhaseIdleCounter = 0; \ m_sTaskData.Reset(); \ pthread_cond_broadcast(&m_tStart ## PHASE ## PhaseCond); \ pthread_mutex_unlock(&m_tStart ## PHASE ## PhaseMutex);
Definition at line 153 of file space_multi_thread_balance_length.cpp.
#define MAIN_WAIT_FOR_END_OF | ( | PHASE | ) |
pthread_mutex_lock(&m_tStart ## PHASE ## PhaseMutex); \ while(m_un ## PHASE ## PhaseIdleCounter < CSimulator::GetInstance().GetNumThreads()) { \ pthread_cond_wait(&m_tStart ## PHASE ## PhaseCond, &m_tStart ## PHASE ## PhaseMutex); \ } \ pthread_mutex_unlock(&m_tStart ## PHASE ## PhaseMutex);
Definition at line 160 of file space_multi_thread_balance_length.cpp.
#define THREAD_DISPATCH_TASK | ( | TASKVEC | ) |
if(! (TASKVEC).empty()) { \ while(! m_sTaskData.Done) { \ pthread_mutex_lock(&m_tFetchTaskMutex); \ while(! m_sTaskData.Used) { \ pthread_cond_wait(&m_tFetchTaskCond, &m_tFetchTaskMutex); \ } \ ++m_sTaskData.Index; \ if(m_sTaskData.Index < (TASKVEC).size()) { \ m_sTaskData.Used = false; \ } \ else { \ m_sTaskData.Done = true; \ } \ pthread_cond_broadcast(&m_tFetchTaskCond); \ pthread_mutex_unlock(&m_tFetchTaskMutex); \ pthread_testcancel(); \ } \ } \ else { \ m_sTaskData.Done = true; \ pthread_mutex_unlock(&m_tFetchTaskMutex); \ pthread_testcancel(); \ }
Definition at line 227 of file space_multi_thread_balance_length.cpp.
#define THREAD_PERFORM_TASK | ( | PHASE, | |
SNIPPET | |||
) |
while(1) { \ pthread_mutex_lock(&m_tFetchTaskMutex); \ while(m_sTaskData.Used && ! m_sTaskData.Done) { \ pthread_cond_wait(&m_tFetchTaskCond, &m_tFetchTaskMutex); \ } \ if(! m_sTaskData.Done) { \ unTaskIndex = m_sTaskData.Index; \ m_sTaskData.Used = true; \ pthread_cond_broadcast(&m_tFetchTaskCond); \ pthread_mutex_unlock(&m_tFetchTaskMutex); \ pthread_testcancel(); \ { \ SNIPPET; \ } \ pthread_testcancel(); \ } \ else { \ pthread_mutex_unlock(&m_tFetchTaskMutex); \ pthread_testcancel(); \ pthread_mutex_lock(&m_tStart ## PHASE ## PhaseMutex); \ ++m_un ## PHASE ## PhaseIdleCounter; \ pthread_cond_broadcast(&m_tStart ## PHASE ## PhaseCond); \ pthread_mutex_unlock(&m_tStart ## PHASE ## PhaseMutex); \ pthread_testcancel(); \ break; \ } \ } \ pthread_testcancel();
Definition at line 269 of file space_multi_thread_balance_length.cpp.
#define THREAD_WAIT_FOR_START_OF | ( | PHASE | ) |
pthread_mutex_lock(&m_tStart ## PHASE ## PhaseMutex); \ while(m_un ## PHASE ## PhaseIdleCounter == CSimulator::GetInstance().GetNumThreads()) { \ pthread_cond_wait(&m_tStart ## PHASE ## PhaseCond, &m_tStart ## PHASE ## PhaseMutex); \ } \ pthread_mutex_unlock(&m_tStart ## PHASE ## PhaseMutex); \ pthread_testcancel();
Definition at line 219 of file space_multi_thread_balance_length.cpp.