mirror of
https://gitee.com/zyjblog/oatpp.git
synced 2025-01-05 17:42:23 +08:00
Implemented copy-assign and move-assign operators for HttpProcessor::Task
to satisfy 'Rule of Two'.
This commit is contained in:
parent
ca19e5b072
commit
29650b0557
@ -244,6 +244,24 @@ HttpProcessor::Task::Task(HttpProcessor::Task &&move)
|
||||
move.m_counter = nullptr;
|
||||
}
|
||||
|
||||
HttpProcessor::Task &HttpProcessor::Task::operator=(const HttpProcessor::Task &t) {
|
||||
if (this != &t) {
|
||||
m_components = t.m_components;
|
||||
m_connection = t.m_connection;
|
||||
m_counter = t.m_counter;
|
||||
(*m_counter)++;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
HttpProcessor::Task &HttpProcessor::Task::operator=(HttpProcessor::Task &&t) {
|
||||
m_components = std::move(t.m_components);
|
||||
m_connection = std::move(t.m_connection);
|
||||
m_counter = t.m_counter;
|
||||
t.m_counter = nullptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void HttpProcessor::Task::run(){
|
||||
|
||||
m_connection->initContexts();
|
||||
|
@ -207,11 +207,25 @@ public:
|
||||
*/
|
||||
Task(const Task ©);
|
||||
|
||||
/**
|
||||
* Copy-Assignment to correctly count tasks.
|
||||
* @param t - Task to copy
|
||||
* @return
|
||||
*/
|
||||
Task &operator=(const Task &t);
|
||||
|
||||
/**
|
||||
* Move-Constructor to correclty count tasks;
|
||||
*/
|
||||
Task(Task &&move);
|
||||
|
||||
/**
|
||||
* Move-Assignment to correctly count tasks.
|
||||
* @param t
|
||||
* @return
|
||||
*/
|
||||
Task &operator=(Task &&t);
|
||||
|
||||
/**
|
||||
* Destructor, needed for counting.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user