tools/Connect.cpp | 6 +----- tools/Stress.cpp | 15 ++++++--------- tools/Tool.cpp | 13 ++++++------- 3 files changed, 13 insertions(+), 21 deletions(-)
New commits: commit fba0be787f389d412691196da63488dc0f3369c5 Author: Pranam Lashkari <lpra...@collabora.com> AuthorDate: Tue Nov 19 23:59:54 2019 +0530 Commit: Jan Holesovsky <ke...@collabora.com> CommitDate: Wed Apr 8 17:22:10 2020 +0200 killpoco: removed Poco::Thread from tools directory Change-Id: I3fc4a04c62a064eaefd5c31452abc4a7fe100fb4 Reviewed-on: https://gerrit.libreoffice.org/c/online/+/83224 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Jan Holesovsky <ke...@collabora.com> diff --git a/tools/Connect.cpp b/tools/Connect.cpp index 8593b0a35..a150bdf99 100644 --- a/tools/Connect.cpp +++ b/tools/Connect.cpp @@ -28,7 +28,6 @@ #include <Poco/Net/SSLManager.h> #include <Poco/SharedPtr.h> #include <Poco/TemporaryFile.h> -#include <Poco/Thread.h> #include <Poco/URI.h> #include <Poco/Util/Application.h> @@ -56,7 +55,6 @@ using Poco::Net::WebSocketException; using Poco::Runnable; using Poco::SharedPtr; using Poco::TemporaryFile; -using Poco::Thread; using Poco::URI; using Poco::Util::Application; @@ -171,9 +169,7 @@ protected: ws.setReceiveTimeout(0); - Thread thread; - Output output(ws); - thread.start(output); + std::thread thread([&ws]{Output(ws).run();}); while (true) { diff --git a/tools/Stress.cpp b/tools/Stress.cpp index b298951db..dc846771f 100644 --- a/tools/Stress.cpp +++ b/tools/Stress.cpp @@ -23,7 +23,6 @@ #include <Poco/Net/HTTPRequest.h> #include <Poco/Net/HTTPResponse.h> -#include <Poco/Thread.h> #include <Poco/URI.h> #include <Poco/Util/Application.h> #include <Poco/Util/HelpFormatter.h> @@ -55,7 +54,6 @@ protected: int main(const std::vector<std::string>& args) override; }; -using Poco::Thread; using Poco::Util::Application; using Poco::Util::HelpFormatter; using Poco::Util::Option; @@ -282,7 +280,8 @@ void Stress::handleOption(const std::string& optionName, int Stress::main(const std::vector<std::string>& args) { - std::vector<std::unique_ptr<Thread>> clients(_numClients * args.size()); + std::vector<std::thread> clients; + clients.reserve(_numClients * args.size()); if (args.size() == 0) { @@ -294,21 +293,19 @@ int Stress::main(const std::vector<std::string>& args) std::vector<std::shared_ptr<Worker>> workers; - unsigned index = 0; for (size_t i = 0; i < args.size(); ++i) { std::cout << "Arg: " << args[i] << std::endl; - for (unsigned j = 0; j < _numClients; ++j, ++index) + for (unsigned j = 0; j < _numClients; ++j) { workers.emplace_back(new Worker(_serverURI, args[i])); - clients[index].reset(new Thread()); - clients[index]->start(*workers[workers.size() - 1]); + clients.emplace_back([&workers]{workers.back()->run();}); } } - for (const auto& client : clients) + for (auto& client : clients) { - client->join(); + client.join(); } if (Stress::Benchmark) diff --git a/tools/Tool.cpp b/tools/Tool.cpp index 91fe4600a..91c9164b6 100644 --- a/tools/Tool.cpp +++ b/tools/Tool.cpp @@ -16,6 +16,7 @@ #include <cstring> #include <fstream> #include <iostream> +#include <thread> #include <sysexits.h> #include <Poco/Net/HTMLForm.h> @@ -28,7 +29,6 @@ #include <Poco/Net/KeyConsoleHandler.h> #include <Poco/Net/AcceptCertificateHandler.h> #include <Poco/StreamCopier.h> -#include <Poco/Thread.h> #include <Poco/URI.h> #include <Poco/Util/Application.h> #include <Poco/Util/OptionSet.h> @@ -69,7 +69,6 @@ using Poco::Net::HTTPClientSession; using Poco::Net::HTTPRequest; using Poco::Net::HTTPResponse; using Poco::Runnable; -using Poco::Thread; using Poco::URI; using Poco::Util::Application; using Poco::Util::OptionSet; @@ -250,26 +249,26 @@ int Tool::main(const std::vector<std::string>& origArgs) return EX_NOINPUT; } - std::vector<std::unique_ptr<Thread>> clients(_numWorkers); + std::vector<std::thread> clients; + clients.reserve(_numWorkers); size_t chunk = (args.size() + _numWorkers - 1) / _numWorkers; size_t offset = 0; for (unsigned i = 0; i < _numWorkers; i++) { - clients[i].reset(new Thread()); size_t toCopy = std::min(args.size() - offset, chunk); if (toCopy > 0) { std::vector< std::string > files( toCopy ); std::copy( args.begin() + offset, args.begin() + offset + toCopy, files.begin() ); offset += toCopy; - clients[i]->start(*(new Worker(*this, files))); + clients.emplace_back([this, &files]{Worker(*this, files).run();}); } } - for (unsigned i = 0; i < _numWorkers; i++) + for (auto& client: clients) { - clients[i]->join(); + client.join(); } return EX_OK; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits