Commit b9952db3 authored by Pascal Palenda's avatar Pascal Palenda
Browse files

Add shutdown message

parent 5736d157
......@@ -81,6 +81,11 @@ namespace ITA
///
void reset ( ) override;
///
/// \copydoc IWorkerInterface::shutdown
///
void shutdown() override;
///
/// \brief Factory function for CWorkerThread.
/// \param pConfig the WorkerConfig used to configure the CWorkerThread.
......
......@@ -172,6 +172,11 @@ namespace ITA
///
audibility_filter::CFilterNetwork* getFilterNetwork ( ) const;
///
/// \brief Shutdown the scheduler safely.
///
void shutdown ( );
private:
///
/// \brief Process a CUpdateScene.
......
......@@ -26,6 +26,7 @@ namespace ITA
enum class ConfigChangeType
{
resetAll, ///< Reset all simulations.
shutdown, ///< Shutdown the system.
changeHRTF, ///< Signal a change in receiver HRTF.
changeDirectivity ///< Signal a change in source directivity.
};
......
......@@ -93,6 +93,11 @@ namespace ITA
///
virtual void reset ( ) = 0;
///
/// \brief Shutdown the worker safely.
///
virtual void shutdown ( ) = 0;
protected:
///
......
......@@ -119,6 +119,17 @@ namespace ITA
m_bResetIndicated = false;
}
void CWorkerThread::shutdown()
{
m_bStopIndicated = true;
m_evTriggerLoop.SignalEvent ( );
// Wait for the end of the simulation
while ( isBusy ( ) ) VistaTimeUtils::Sleep ( 100 );
StopGently ( true );
}
std::unique_ptr<IWorkerInterface> CWorkerThread::createWorker (
const std::shared_ptr<IWorkerInterface::WorkerConfig>& pConfig, ISchedulerInterface* pParent )
{
......
......@@ -184,6 +184,9 @@ namespace ITA
case CUpdateConfig::ConfigChangeType::resetAll:
reset ( );
break;
case CUpdateConfig::ConfigChangeType::shutdown:
shutdown ( );
break;
default:
ITA_EXCEPT_INVALID_PARAMETER ( "Unkown type of config change" );
}
......@@ -353,5 +356,18 @@ namespace ITA
{
return m_pFilterNetwork.get ( );
}
void CScheduler::shutdown()
{
m_qUpdateQueue.clear ( );
m_lPendingUpdateList.clear ( );
m_lUpdateList.clear ( );
// signal the reset to the workers
for ( auto& worker : m_vWorker )
{
worker->shutdown ( );
}
}
} // namespace simulation_scheduler
} // namespace ITA
\ No newline at end of file
Supports Markdown
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