@ -102,6 +102,7 @@ enum EState
STATE_IDLE ,
STATE_IDLE ,
STATE_RELOAD_SHEETS ,
STATE_RELOAD_SHEETS ,
STATE_DATABASE_STATUS ,
STATE_DATABASE_STATUS ,
STATE_RUNNABLE_TASK ,
} ;
} ;
/// Data
/// Data
@ -112,6 +113,7 @@ CDatabaseStatus *s_DatabaseStatus = NULL;
CPipelineInterfaceImpl * s_PipelineInterfaceImpl = NULL ;
CPipelineInterfaceImpl * s_PipelineInterfaceImpl = NULL ;
EState s_State = STATE_IDLE ;
EState s_State = STATE_IDLE ;
std : : string s_StateRunnableTaskName = " " ;
CMutex s_StateMutex ;
CMutex s_StateMutex ;
std : : vector < NLMISC : : CLibrary * > s_LoadedLibraries ;
std : : vector < NLMISC : : CLibrary * > s_LoadedLibraries ;
@ -141,14 +143,51 @@ bool tryStateTask(EState state, IRunnable *task)
}
}
s_StateMutex . leave ( ) ;
s_StateMutex . leave ( ) ;
if ( ! result ) return false ;
if ( ! result ) return false ;
nlassert ( s_State ! = STATE_IDLE ) ;
s_TaskManager - > addTask ( task ) ;
s_TaskManager - > addTask ( task ) ;
return true ;
return true ;
}
}
} /* anonymous namespace */
bool tryRunnableTask ( std : : string stateName , IRunnable * task )
{
// copy paste from above.
bool result = false ;
s_StateMutex . enter ( ) ;
result = ( s_State = = STATE_IDLE ) ;
if ( result )
{
s_State = STATE_RUNNABLE_TASK ;
s_StateRunnableTaskName = stateName ;
}
s_StateMutex . leave ( ) ;
if ( ! result ) return false ;
nlassert ( s_State ! = STATE_IDLE ) ;
s_TaskManager - > addTask ( task ) ;
return true ;
}
void endedRunnableTask ( )
{
nlassert ( s_State ! = STATE_IDLE ) ;
s_StateMutex . enter ( ) ;
s_State = STATE_IDLE ;
s_StateMutex . leave ( ) ;
}
// ******************************************************************
// ******************************************************************
namespace {
void initSheets ( )
void initSheets ( )
{
{
std : : string leveldesignDfnDirectory = IService : : getInstance ( ) - > ConfigFile . getVar ( " LeveldesignDfnDirectory " ) . asString ( ) ;
std : : string leveldesignDfnDirectory = IService : : getInstance ( ) - > ConfigFile . getVar ( " LeveldesignDfnDirectory " ) . asString ( ) ;
@ -186,9 +225,7 @@ class CReloadSheets : public IRunnable
releaseSheets ( ) ;
releaseSheets ( ) ;
initSheets ( ) ;
initSheets ( ) ;
s_StateMutex . enter ( ) ;
endedRunnableTask ( ) ;
s_State = STATE_IDLE ;
s_StateMutex . leave ( ) ;
}
}
} ;
} ;
CReloadSheets s_ReloadSheets ;
CReloadSheets s_ReloadSheets ;
@ -207,9 +244,7 @@ class CUpdateDatabaseStatus : public IRunnable
void databaseStatusUpdated ( )
void databaseStatusUpdated ( )
{
{
s_StateMutex . enter ( ) ;
endedRunnableTask ( ) ;
s_State = STATE_IDLE ;
s_StateMutex . leave ( ) ;
}
}
virtual void run ( )
virtual void run ( )
@ -349,6 +384,9 @@ NLMISC_DYNVARIABLE(std::string, pipelineServiceState, "State of the pipeline ser
case PIPELINE : : STATE_DATABASE_STATUS :
case PIPELINE : : STATE_DATABASE_STATUS :
* pointer = " DATABASE_STATUS " ;
* pointer = " DATABASE_STATUS " ;
break ;
break ;
case PIPELINE : : STATE_RUNNABLE_TASK :
* pointer = PIPELINE : : s_StateRunnableTaskName ;
break ;
}
}
}
}
}
}