cmWorkerPool: Convert RunCommand signature to move semantics

This commit is contained in:
Brad King 2025-01-31 11:48:05 -05:00
parent c091fd1420
commit cf7ba6d43d
2 changed files with 10 additions and 10 deletions

View File

@ -159,7 +159,7 @@ public:
// -- Runtime // -- Runtime
void setup(cmWorkerPool::ProcessResultT* result, bool mergedOutput, void setup(cmWorkerPool::ProcessResultT* result, bool mergedOutput,
std::vector<std::string> const& command, std::vector<std::string> command,
std::string const& workingDirectory = std::string()); std::string const& workingDirectory = std::string());
bool start(uv_loop_t* uv_loop, std::function<void()> finishedCallback); bool start(uv_loop_t* uv_loop, std::function<void()> finishedCallback);
@ -188,11 +188,11 @@ private:
void cmUVReadOnlyProcess::setup(cmWorkerPool::ProcessResultT* result, void cmUVReadOnlyProcess::setup(cmWorkerPool::ProcessResultT* result,
bool mergedOutput, bool mergedOutput,
std::vector<std::string> const& command, std::vector<std::string> command,
std::string const& workingDirectory) std::string const& workingDirectory)
{ {
this->Setup_.WorkingDirectory = workingDirectory; this->Setup_.WorkingDirectory = workingDirectory;
this->Setup_.Command = command; this->Setup_.Command = std::move(command);
this->Setup_.Result = result; this->Setup_.Result = result;
this->Setup_.MergedOutput = mergedOutput; this->Setup_.MergedOutput = mergedOutput;
} }
@ -396,7 +396,7 @@ public:
* Run an external process * Run an external process
*/ */
bool RunProcess(cmWorkerPool::ProcessResultT& result, bool RunProcess(cmWorkerPool::ProcessResultT& result,
std::vector<std::string> const& command, std::vector<std::string> command,
std::string const& workingDirectory); std::string const& workingDirectory);
private: private:
@ -429,7 +429,7 @@ cmWorkerPoolWorker::~cmWorkerPoolWorker()
} }
bool cmWorkerPoolWorker::RunProcess(cmWorkerPool::ProcessResultT& result, bool cmWorkerPoolWorker::RunProcess(cmWorkerPool::ProcessResultT& result,
std::vector<std::string> const& command, std::vector<std::string> command,
std::string const& workingDirectory) std::string const& workingDirectory)
{ {
if (command.empty()) { if (command.empty()) {
@ -439,7 +439,8 @@ bool cmWorkerPoolWorker::RunProcess(cmWorkerPool::ProcessResultT& result,
{ {
std::lock_guard<std::mutex> lock(this->Proc_.Mutex); std::lock_guard<std::mutex> lock(this->Proc_.Mutex);
this->Proc_.ROP = cm::make_unique<cmUVReadOnlyProcess>(); this->Proc_.ROP = cm::make_unique<cmUVReadOnlyProcess>();
this->Proc_.ROP->setup(&result, true, command, workingDirectory); this->Proc_.ROP->setup(&result, true, std::move(command),
workingDirectory);
} }
// Send asynchronous process start request to libuv loop // Send asynchronous process start request to libuv loop
this->Proc_.Request.send(); this->Proc_.Request.send();
@ -731,12 +732,12 @@ void cmWorkerPoolInternal::Work(unsigned int workerIndex)
cmWorkerPool::JobT::~JobT() = default; cmWorkerPool::JobT::~JobT() = default;
bool cmWorkerPool::JobT::RunProcess(ProcessResultT& result, bool cmWorkerPool::JobT::RunProcess(ProcessResultT& result,
std::vector<std::string> const& command, std::vector<std::string> command,
std::string const& workingDirectory) std::string const& workingDirectory)
{ {
// Get worker by index // Get worker by index
auto* worker = this->Pool_->Int_->Workers.at(this->WorkerIndex_).get(); auto* worker = this->Pool_->Int_->Workers.at(this->WorkerIndex_).get();
return worker->RunProcess(result, command, workingDirectory); return worker->RunProcess(result, std::move(command), workingDirectory);
} }
cmWorkerPool::cmWorkerPool() cmWorkerPool::cmWorkerPool()

View File

@ -102,8 +102,7 @@ public:
* Run an external read only process. * Run an external read only process.
* Use only during JobT::Process() call! * Use only during JobT::Process() call!
*/ */
bool RunProcess(ProcessResultT& result, bool RunProcess(ProcessResultT& result, std::vector<std::string> command,
std::vector<std::string> const& command,
std::string const& workingDirectory); std::string const& workingDirectory);
private: private: