From 24190edcf703908f5d2111aaf215bfa48349f979 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Tue, 31 Jul 2012 14:57:16 +0200 Subject: [PATCH] Added: #1440 Begin status update --HG-- branch : build_pipeline_v3 --- .../service/module_pipeline_slave.cpp | 75 ++++++++++++++++++- 1 file changed, 71 insertions(+), 4 deletions(-) diff --git a/code/nel/tools/pipeline/service/module_pipeline_slave.cpp b/code/nel/tools/pipeline/service/module_pipeline_slave.cpp index 698208e6b..51f7d571d 100644 --- a/code/nel/tools/pipeline/service/module_pipeline_slave.cpp +++ b/code/nel/tools/pipeline/service/module_pipeline_slave.cpp @@ -33,6 +33,7 @@ // NeL includes #include #include +#include // Project includes #include "info_flags.h" @@ -87,6 +88,8 @@ public: }; TSlaveTaskState m_SlaveTaskState; // only set and used by update!! used on other threads for sanity checks + NLMISC::CTaskManager *m_TaskManager; + NLMISC::CSynchronized m_StatusUpdateMasterDone; NLMISC::CSynchronized m_StatusUpdateSlaveDone; @@ -94,10 +97,12 @@ public: CProcessPluginInfo m_ActivePlugin; public: - CModulePipelineSlave() : m_Master(NULL), m_TestCommand(false), m_ReloadSheetsState(REQUEST_NONE), m_BuildReadyState(false), m_SlaveTaskState(IDLE_WAIT_MASTER), m_StatusUpdateMasterDone("StatusUpdateMasterDone"), m_StatusUpdateSlaveDone("StatusUpdateSlaveDone"), m_ActiveProject(false) + CModulePipelineSlave() : m_Master(NULL), m_TestCommand(false), m_ReloadSheetsState(REQUEST_NONE), m_BuildReadyState(false), m_SlaveTaskState(IDLE_WAIT_MASTER), m_TaskManager(NULL), m_StatusUpdateMasterDone("StatusUpdateMasterDone"), m_StatusUpdateSlaveDone("StatusUpdateSlaveDone"), m_ActiveProject(false) { NLMISC::CSynchronized::CAccessor(&m_StatusUpdateMasterDone).value() = false; NLMISC::CSynchronized::CAccessor(&m_StatusUpdateSlaveDone).value() = false; + + m_TaskManager = new NLMISC::CTaskManager(); } virtual ~CModulePipelineSlave() @@ -107,9 +112,11 @@ public: abortBuildTask(NULL); leaveBuildReadyState(NULL); - // TODO: + // TODO? // wait till build task has exited if still was running // wait for other things to exist in case there are... + delete m_TaskManager; + m_TaskManager = NULL; // temp sanity nlassert(m_SlaveTaskState == IDLE_WAIT_MASTER); @@ -193,6 +200,8 @@ public: if (NLMISC::CSynchronized::CAccessor(&m_StatusUpdateMasterDone).value() && NLMISC::CSynchronized::CAccessor(&m_StatusUpdateSlaveDone).value()) { + nlinfo("Slave task: Status update done"); + m_SlaveTaskState = SOMEWHERE_INBETWEEN; // Done with the status updating, now do something fancey // ... TODO ... } @@ -205,13 +214,67 @@ public: /////////////////////////////////////////////////////////////////// + class CStatusUpdateSlaveTask : public NLMISC::IRunnable + { + public: + CStatusUpdateSlaveTask(CModulePipelineSlave *slave) : m_Slave(slave) { } + virtual void run() + { + // TODO... + + // Mark as done + { + NLMISC::CSynchronized::CAccessor(&m_Slave->m_StatusUpdateSlaveDone).value() = true; + CInfoFlags::getInstance()->removeFlag(PIPELINE_INFO_STATUS_UPDATE_SLAVE); + } + + delete this; + } + private: + CModulePipelineSlave *m_Slave; + }; + /// Begin with the status update of the current task void beginTaskStatusUpdate() { // Set the task state m_SlaveTaskState = STATUS_UPDATE; + nlinfo("Slave task: Status update begin"); - // TODO: Start the client and master status update + // Sanity check + { + nlassert(NLMISC::CSynchronized::CAccessor(&m_StatusUpdateMasterDone).value() == false); + nlassert(NLMISC::CSynchronized::CAccessor(&m_StatusUpdateSlaveDone).value() == false); + } + + // Start the client update + CInfoFlags::getInstance()->addFlag(PIPELINE_INFO_STATUS_UPDATE_SLAVE); + m_TaskManager->addTask(new CStatusUpdateSlaveTask(this)); + + // Start the master update + CInfoFlags::getInstance()->addFlag(PIPELINE_INFO_STATUS_UPDATE_MASTER); + std::vector result; + switch (m_ActivePlugin.InfoType) + { + case PIPELINE::PLUGIN_REGISTERED_CLASS: + { + PIPELINE::IProcessInfo *processInfo = static_cast(NLMISC::CClassRegistry::create(m_ActivePlugin.Info)); + // processInfo->setPipelineProcess(pipelineProcess); // .... TODO .... + processInfo->getDependentDirectories(result); + for (std::vector::iterator it = result.begin(), end = result.end(); it != end; ++it) + m_Master->vectorPushString(this, PIPELINE::macroPath(*it)); + result.clear(); + processInfo->getDependentFiles(result); + for (std::vector::iterator it = result.begin(), end = result.end(); it != end; ++it) + m_Master->vectorPushString(this, PIPELINE::macroPath(*it)); + result.clear(); + } + break; + default: + nlwarning("Plugin type not implemented"); + break; + } + m_Master->updateDatabaseStatusByVector(this); } /////////////////////////////////////////////////////////////////// @@ -232,6 +295,9 @@ public: //CModulePipelineMasterProxy master(sender); //master.slaveRefusedBuildTask(this); + + // Begin with status update of the dependent directories and files on the master, and previous output files on the slave + beginTaskStatusUpdate(); } virtual void abortBuildTask(NLNET::IModuleProxy *sender) @@ -255,10 +321,11 @@ public: } else { + nldebug("Master updated database status"); nlassert(m_SlaveTaskState == STATUS_UPDATE); // Notify the update function that the master update has arrived. NLMISC::CSynchronized::CAccessor(&m_StatusUpdateMasterDone).value() = true; - CInfoFlags::getInstance()->removeFlag(PIPELINE_INFO_STATUS_UPDATE_SLAVE); + CInfoFlags::getInstance()->removeFlag(PIPELINE_INFO_STATUS_UPDATE_MASTER); } }