mirror of
https://github.com/oatpp/oatpp.git
synced 2024-11-27 08:30:07 +08:00
Implemented move-constructor of HttpProcessor::Task
to use its performance-gain over copy.
This commit is contained in:
parent
8badb89a1c
commit
ca19e5b072
@ -74,7 +74,7 @@ void HttpConnectionHandler::handleConnection(const std::shared_ptr<oatpp::data::
|
||||
connection->setInputStreamIOMode(oatpp::data::stream::IOMode::BLOCKING);
|
||||
|
||||
/* Create working thread */
|
||||
std::thread thread(&HttpProcessor::Task::run, HttpProcessor::Task(m_components, connection, &m_spawns));
|
||||
std::thread thread(&HttpProcessor::Task::run, std::move(HttpProcessor::Task(m_components, connection, &m_spawns)));
|
||||
|
||||
/* Get hardware concurrency -1 in order to have 1cpu free of workers. */
|
||||
v_int32 concurrency = oatpp::concurrency::getHardwareConcurrency();
|
||||
|
@ -236,6 +236,14 @@ HttpProcessor::Task::Task(const HttpProcessor::Task ©)
|
||||
(*m_counter)++;
|
||||
}
|
||||
|
||||
HttpProcessor::Task::Task(HttpProcessor::Task &&move)
|
||||
: m_components(std::move(move.m_components))
|
||||
, m_connection(std::move(move.m_connection))
|
||||
, m_counter(move.m_counter)
|
||||
{
|
||||
move.m_counter = nullptr;
|
||||
}
|
||||
|
||||
void HttpProcessor::Task::run(){
|
||||
|
||||
m_connection->initContexts();
|
||||
@ -258,7 +266,9 @@ void HttpProcessor::Task::run(){
|
||||
|
||||
}
|
||||
HttpProcessor::Task::~Task() {
|
||||
(*m_counter)--;
|
||||
if (m_counter != nullptr) {
|
||||
(*m_counter)--;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -207,6 +207,11 @@ public:
|
||||
*/
|
||||
Task(const Task ©);
|
||||
|
||||
/**
|
||||
* Move-Constructor to correclty count tasks;
|
||||
*/
|
||||
Task(Task &&move);
|
||||
|
||||
/**
|
||||
* Destructor, needed for counting.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user