Commit 284ee4cf authored by Pascal Palenda's avatar Pascal Palenda
Browse files

Change list to map

parent 0207b44f
......@@ -231,9 +231,9 @@ namespace ITA
std::list<std::unique_ptr<IUpdateMessage>> m_lUpdateList;
///
/// \brief List with CUpdateScenes pending for simulation.
/// \brief Map with CUpdateScenes pending for simulation keyed by their reference ID.
///
std::list<std::unique_ptr<CUpdateScene>> m_lPendingUpdateList;
std::unordered_map<int, std::unique_ptr<CUpdateScene>> m_mPendingUpdates;
///
/// \brief Map containing all latest simulated updates.
......
......@@ -156,7 +156,24 @@ namespace ITA
if ( bAudible )
{
PROFILER_VALUE ( "Audible Update Scenes", pUpdate->GetID ( ) );
m_lPendingUpdateList.push_back ( std::move ( pUpdate ) );
#ifdef WITH_PROFILER
const auto pendingUpdateIterator = m_mPendingUpdates.find ( pUpdate->GetReferenceID ( ) );
if ( pendingUpdateIterator != m_mPendingUpdates.end ( ) )
{
PROFILER_VALUE ( "Removed Updates", pendingUpdateIterator->second->GetID ( ) );
m_mPendingUpdates [pUpdate->GetReferenceID ( )] = std::move ( pUpdate );
}
else
{
m_mPendingUpdates [pUpdate->GetReferenceID ( )] = std::move ( pUpdate );
}
#else
m_mPendingUpdates [pUpdate->GetReferenceID ( )] = std::move ( pUpdate );
#endif
}
else
{
......@@ -202,7 +219,7 @@ namespace ITA
// The loop was on hold, clear all update lists.
m_qUpdateQueue.clear ( );
m_lUpdateList.clear ( );
m_lPendingUpdateList.clear ( );
m_mPendingUpdates.clear ( );
// start the loop again.
m_bResetIndicated = true;
......@@ -269,22 +286,19 @@ namespace ITA
// Now, the list only contains non valid unique_ptr, we can clear it.
m_lUpdateList.clear ( );
// replace old updates
if ( m_bReplaceUpdates )
CReplacementFilter::FilterReplace ( m_lPendingUpdateList );
PROFILER_SECTION ( "Distribute Updates to Worker" );
// distribute updates to the worker
for ( auto workerIter = m_vWorker.begin ( );
!m_lPendingUpdateList.empty ( ) && workerIter != m_vWorker.end ( );
!m_mPendingUpdates.empty ( ) && workerIter != m_vWorker.end ( );
++workerIter )
{
auto& worker = *workerIter;
if ( !worker->IsBusy ( ) )
{
// get the update out of the list.
auto update = std::move ( m_lPendingUpdateList.front ( ) );
m_lPendingUpdateList.pop_front ( );
auto update = std::move ( m_mPendingUpdates.begin ( )->second );
m_mPendingUpdates.erase ( m_mPendingUpdates.begin ( ) );
PROFILER_VALUE ( "Update Scence To Simulator", update->GetID ( ) );
......@@ -297,13 +311,13 @@ namespace ITA
}
PROFILER_END_SECTION ( );
PROFILER_VALUE ( "Number of Pending Updates After Loop", m_lPendingUpdateList.size ( ) );
PROFILER_VALUE ( "Number of Pending Updates After Loop", m_mPendingUpdates.size ( ) );
// If we still have updates, we'd want the loop to go again to see if a worker can simulate the pending updates.
if ( !m_lPendingUpdateList.empty ( ) )
if ( !m_mPendingUpdates.empty ( ) )
m_evTriggerLoop.SignalEvent ( );
PROFILER_END_SECTION();
PROFILER_END_SECTION ( );
return true;
}
......@@ -357,10 +371,10 @@ namespace ITA
return m_pFilterNetwork.get ( );
}
void CScheduler::Shutdown()
void CScheduler::Shutdown ( )
{
m_qUpdateQueue.clear ( );
m_lPendingUpdateList.clear ( );
m_mPendingUpdates.clear ( );
m_lUpdateList.clear ( );
// signal the reset to the workers
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment