Index: src/libchcore/TTask.h =================================================================== diff -u -N -r2e384de25de613cb582a966df7d1cb9468f1c825 -re96806b7f8ff7ca7e9f4afbea603e6351a3dc3e3 --- src/libchcore/TTask.h (.../TTask.h) (revision 2e384de25de613cb582a966df7d1cb9468f1c825) +++ src/libchcore/TTask.h (.../TTask.h) (revision e96806b7f8ff7ca7e9f4afbea603e6351a3dc3e3) @@ -35,154 +35,153 @@ #include "ISerializer.h" #include "TTaskBaseData.h" -BEGIN_CHCORE_NAMESPACE +namespace chcore +{ + class TBufferSizes; -class TBufferSizes; + /////////////////////////////////////////////////////////////////////////// + // TTask -/////////////////////////////////////////////////////////////////////////// -// TTask + class LIBCHCORE_API TTask + { + private: + TTask(const ISerializerPtr& spSerializer, const IFeedbackHandlerPtr& spFeedbackHandler); -class LIBCHCORE_API TTask -{ -private: - TTask(const ISerializerPtr& spSerializer, const IFeedbackHandlerPtr& spFeedbackHandler); + public: + ~TTask(); -public: - ~TTask(); + void SetTaskState(ETaskCurrentState eTaskState); + ETaskCurrentState GetTaskState() const; - void SetTaskState(ETaskCurrentState eTaskState); - ETaskCurrentState GetTaskState() const; + bool IsRunning() const; - bool IsRunning() const; + // m_nBufferSize + void SetBufferSizes(const TBufferSizes& bsSizes); + void GetBufferSizes(TBufferSizes& bsSizes); - // m_nBufferSize - void SetBufferSizes(const TBufferSizes& bsSizes); - void GetBufferSizes(TBufferSizes& bsSizes); + TSmartPath GetLogPath() const; + TString GetTaskName() const; - TSmartPath GetLogPath() const; - TString GetTaskName() const; + // thread + void SetPriority(int nPriority); - // thread - void SetPriority(int nPriority); + void Load(); + void Store(); - void Load(); - void Store(); + void BeginProcessing(); - void BeginProcessing(); + void PauseProcessing(); // pause + void ResumeProcessing(); // resume + bool RetryProcessing(); // retry + void RestartProcessing(); // from beginning + void CancelProcessing(); // cancel - void PauseProcessing(); // pause - void ResumeProcessing(); // resume - bool RetryProcessing(); // retry - void RestartProcessing(); // from beginning - void CancelProcessing(); // cancel + void GetStatsSnapshot(TTaskStatsSnapshotPtr& spSnapshot); - void GetStatsSnapshot(TTaskStatsSnapshotPtr& spSnapshot); + void SetForceFlag(bool bFlag = true); + bool GetForceFlag(); - void SetForceFlag(bool bFlag = true); - bool GetForceFlag(); + private: + void SetTaskDefinition(const TTaskDefinition& rTaskDefinition); -private: - void SetTaskDefinition(const TTaskDefinition& rTaskDefinition); + void SetLogPath(const TSmartPath& pathLog); + icpf::log_file& GetLog(); - void SetLogPath(const TSmartPath& pathLog); - icpf::log_file& GetLog(); + // methods are called when task is being added or removed from the global task array + /// Method is called when this task is being added to a TTaskManager object + void OnRegisterTask(); + /// Method is called when task is being removed from the TTaskManager object + void OnUnregisterTask(); - // methods are called when task is being added or removed from the global task array - /// Method is called when this task is being added to a TTaskManager object - void OnRegisterTask(); - /// Method is called when task is being removed from the TTaskManager object - void OnUnregisterTask(); + /// Method is called when processing is being started + void OnBeginOperation(); + /// Method is called when processing is being ended + void OnEndOperation(); - /// Method is called when processing is being started - void OnBeginOperation(); - /// Method is called when processing is being ended - void OnEndOperation(); + /// Thread function that delegates call to the TTask::ThrdProc + static DWORD WINAPI DelegateThreadProc(LPVOID pParam); - /// Thread function that delegates call to the TTask::ThrdProc - static DWORD WINAPI DelegateThreadProc(LPVOID pParam); + /// Main function for the task processing thread + DWORD WINAPI ThrdProc(); - /// Main function for the task processing thread - DWORD WINAPI ThrdProc(); + TSubTaskBase::ESubOperationResult CheckForWaitState(); - TSubTaskBase::ESubOperationResult CheckForWaitState(); + // m_nStatus + void SetStatusNL(UINT nStatus, UINT nMask); + UINT GetStatusNL(UINT nMask = 0xffffffff); - // m_nStatus - void SetStatusNL(UINT nStatus, UINT nMask); - UINT GetStatusNL(UINT nMask = 0xffffffff); + void SetForceFlagNL(bool bFlag = true); + bool GetForceFlagNL(); - void SetForceFlagNL(bool bFlag = true); - bool GetForceFlagNL(); + void SetContinueFlag(bool bFlag = true); + bool GetContinueFlag(); + void SetContinueFlagNL(bool bFlag = true); + bool GetContinueFlagNL(); - void SetContinueFlag(bool bFlag = true); - bool GetContinueFlag(); - void SetContinueFlagNL(bool bFlag = true); - bool GetContinueFlagNL(); + bool CanBegin(); - bool CanBegin(); + void KillThread(); + void RequestStopThread(); - void KillThread(); - void RequestStopThread(); + static void OnCfgOptionChanged(const TStringSet& rsetChanges, void* pParam); - static void OnCfgOptionChanged(const TStringSet& rsetChanges, void* pParam); + ISerializerPtr GetSerializer() const; - ISerializerPtr GetSerializer() const; - -private: - // serialization + private: + // serialization #pragma warning(push) #pragma warning(disable: 4251) - ISerializerPtr m_spSerializer; - IFeedbackHandlerPtr m_spInternalFeedbackHandler; + ISerializerPtr m_spSerializer; + IFeedbackHandlerPtr m_spInternalFeedbackHandler; #pragma warning(pop) - // base data - TTaskBaseData m_tBaseData; + // base data + TTaskBaseData m_tBaseData; - // basic information + // basic information #pragma warning(push) #pragma warning(disable: 4251) - TBasePathDataContainerPtr m_spSrcPaths; + TBasePathDataContainerPtr m_spSrcPaths; #pragma warning(pop) - // Global task settings - TConfig m_tConfiguration; + // Global task settings + TConfig m_tConfiguration; - TSubTasksArray m_tSubTasksArray; + TSubTasksArray m_tSubTasksArray; - TSubTaskContext m_tSubTaskContext; + TSubTaskContext m_tSubTaskContext; - TTaskConfigTracker m_cfgTracker; + TTaskConfigTracker m_cfgTracker; - // current task state (derivatives of the task initial information) + // current task state (derivatives of the task initial information) - // task settings - TFileFiltersArray m_afFilters; // filtering settings for files (will be filtered according to the rules inside when searching for files) + // task settings + TFileFiltersArray m_afFilters; // filtering settings for files (will be filtered according to the rules inside when searching for files) - bool m_bForce; // if the continuation of tasks should be independent of max concurrently running task limit - bool m_bContinue; // allows task to continue + bool m_bForce; // if the continuation of tasks should be independent of max concurrently running task limit + bool m_bContinue; // allows task to continue - // other helpers - icpf::log_file m_log; ///< Log file where task information will be stored + // other helpers + icpf::log_file m_log; ///< Log file where task information will be stored - // Local filesystem access - TLocalFilesystem m_fsLocal; + // Local filesystem access + TLocalFilesystem m_fsLocal; - /// Thread controlling object - TWorkerThreadController m_workerThread; + /// Thread controlling object + TWorkerThreadController m_workerThread; - /// Mutex for locking concurrent access to members of this class + /// Mutex for locking concurrent access to members of this class #pragma warning(push) #pragma warning(disable: 4251) - TTaskLocalStatsInfo m_tLocalStats; // local statistics + TTaskLocalStatsInfo m_tLocalStats; // local statistics - mutable boost::shared_mutex m_lock; + mutable boost::shared_mutex m_lock; #pragma warning(pop) - friend class TTaskManager; -}; + friend class TTaskManager; + }; -typedef boost::shared_ptr TTaskPtr; + typedef boost::shared_ptr TTaskPtr; +} -END_CHCORE_NAMESPACE - #endif