diff options
author | Wouter Klouwen <wouter.klouwen@youview.com> | 2017-11-20 20:55:13 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-12-04 15:43:14 (GMT) |
commit | 66419bc04620c5748df77e2b563d65b0e97b623a (patch) | |
tree | 0c6e38ba923c4eb95c3d5d829c83a849d58eb52a /Source/CTest/cmProcess.h | |
parent | 923b8fadd5fe6af56197cf3916a3292b60c0e8db (diff) | |
download | CMake-66419bc04620c5748df77e2b563d65b0e97b623a.zip CMake-66419bc04620c5748df77e2b563d65b0e97b623a.tar.gz CMake-66419bc04620c5748df77e2b563d65b0e97b623a.tar.bz2 |
CTest: convert timeouts to std::chrono::duration
This commit continues the refactoring of CTest to adopt std::chrono.
After the last sets of changes that introduced std::chrono::steady_clock
and std::chrono::system_clock respectively, it makes sense to have all
the timeouts be stored as std::chrono::duration.
No functional change intended.
Diffstat (limited to 'Source/CTest/cmProcess.h')
-rw-r--r-- | Source/CTest/cmProcess.h | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/Source/CTest/cmProcess.h b/Source/CTest/cmProcess.h index ddd69b6..cbb611d 100644 --- a/Source/CTest/cmProcess.h +++ b/Source/CTest/cmProcess.h @@ -10,6 +10,13 @@ #include <string> #include <vector> +/* + * A wrapper function for cmsysProcess_SetTimeout that takes an + * std::chrono::duration. For convenience only. + */ +void cmsysProcess_SetTimeout(cmsysProcess* process, + std::chrono::duration<double> timeout); + /** \class cmProcess * \brief run a process with c++ * @@ -24,8 +31,8 @@ public: void SetCommand(const char* command); void SetCommandArguments(std::vector<std::string> const& arg); void SetWorkingDirectory(const char* dir) { this->WorkingDirectory = dir; } - void SetTimeout(double t) { this->Timeout = t; } - void ChangeTimeout(double t); + void SetTimeout(std::chrono::duration<double> t) { this->Timeout = t; } + void ChangeTimeout(std::chrono::duration<double> t); void ResetStartTime(); // Return true if the process starts bool StartProcess(); @@ -37,7 +44,7 @@ public: int GetId() { return this->Id; } void SetId(int id) { this->Id = id; } int GetExitValue() { return this->ExitValue; } - double GetTotalTime() { return this->TotalTime; } + std::chrono::duration<double> GetTotalTime() { return this->TotalTime; } int GetExitException(); std::string GetExitExceptionString(); /** @@ -47,12 +54,13 @@ public: * cmsysProcess_Pipe_STDOUT = Line came from stdout or stderr * cmsysProcess_Pipe_Timeout = Timeout expired while waiting */ - int GetNextOutputLine(std::string& line, double timeout); + int GetNextOutputLine(std::string& line, + std::chrono::duration<double> timeout); private: - double Timeout; + std::chrono::duration<double> Timeout; std::chrono::steady_clock::time_point StartTime; - double TotalTime; + std::chrono::duration<double> TotalTime; cmsysProcess* Process; class Buffer : public std::vector<char> { |