mirror of
https://gitee.com/zyjblog/oatpp.git
synced 2024-12-22 22:16:37 +08:00
Rebased this branch from v1.3.0 branch
This commit is contained in:
parent
f1b55ea625
commit
57099a08de
@ -176,16 +176,23 @@ CoroutineStarter::CoroutineStarter(CoroutineStarter&& other)
|
||||
}
|
||||
|
||||
CoroutineStarter::~CoroutineStarter() {
|
||||
freeCoroutines();
|
||||
if(m_first != nullptr) {
|
||||
auto curr = m_first;
|
||||
while(curr != nullptr) {
|
||||
AbstractCoroutine* next = nullptr;
|
||||
if(curr->m_parentReturnAction.m_type == Action::TYPE_COROUTINE) {
|
||||
next = curr->m_parentReturnAction.m_data.coroutine;
|
||||
}
|
||||
delete curr;
|
||||
curr = next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Move assignment operator.
|
||||
*/
|
||||
CoroutineStarter& CoroutineStarter::operator=(CoroutineStarter&& other) {
|
||||
if (this == std::addressof(other)) return *this;
|
||||
|
||||
freeCoroutines();
|
||||
m_first = other.m_first;
|
||||
m_last = other.m_last;
|
||||
other.m_first = nullptr;
|
||||
@ -217,21 +224,6 @@ CoroutineStarter& CoroutineStarter::next(CoroutineStarter&& starter) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
void CoroutineStarter::freeCoroutines()
|
||||
{
|
||||
if (m_first != nullptr) {
|
||||
auto curr = m_first;
|
||||
while (curr != nullptr) {
|
||||
AbstractCoroutine* next = nullptr;
|
||||
if (curr->m_parentReturnAction.m_type == Action::TYPE_COROUTINE) {
|
||||
next = curr->m_parentReturnAction.m_data.coroutine;
|
||||
}
|
||||
delete curr;
|
||||
curr = next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// CoroutineHandle
|
||||
|
||||
|
@ -361,11 +361,6 @@ class CoroutineStarter {
|
||||
private:
|
||||
AbstractCoroutine* m_first;
|
||||
AbstractCoroutine* m_last;
|
||||
|
||||
private:
|
||||
|
||||
void freeCoroutines();
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
@ -622,8 +617,8 @@ public:
|
||||
* @return - &id:oatpp::async::CoroutineStarter;.
|
||||
*/
|
||||
template<typename ...ConstructorArgs>
|
||||
static CoroutineStarter start(ConstructorArgs&&... args) {
|
||||
return new T(std::forward<ConstructorArgs>(args)...);
|
||||
static CoroutineStarter start(ConstructorArgs... args) {
|
||||
return new T(args...);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -711,9 +706,6 @@ public:
|
||||
* Move assignment operator.
|
||||
*/
|
||||
StarterForResult& operator=(StarterForResult&& other) {
|
||||
if (this == std::addressof(other)) return *this;
|
||||
|
||||
delete m_coroutine;
|
||||
m_coroutine = other.m_coroutine;
|
||||
other.m_coroutine = nullptr;
|
||||
return *this;
|
||||
@ -787,7 +779,7 @@ public:
|
||||
* @param ptr - pointer of the function to call.
|
||||
* @return - Action.
|
||||
*/
|
||||
Action call(const AbstractCoroutine::FunctionPtr& ptr) override {
|
||||
virtual Action call(const AbstractCoroutine::FunctionPtr& ptr) override {
|
||||
Function f = static_cast<Function>(ptr);
|
||||
return (static_cast<T*>(this)->*f)();
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ bool Processor::iterate(v_int32 numIterations) {
|
||||
|
||||
auto CP = m_queue.first;
|
||||
if (CP == nullptr) {
|
||||
break;
|
||||
goto end_loop;
|
||||
}
|
||||
if (CP->finished()) {
|
||||
m_queue.popFrontNoData();
|
||||
@ -229,6 +229,8 @@ bool Processor::iterate(v_int32 numIterations) {
|
||||
|
||||
}
|
||||
|
||||
end_loop:
|
||||
|
||||
popTasks();
|
||||
|
||||
std::lock_guard<oatpp::concurrency::SpinLock> lock(m_taskLock);
|
||||
|
Loading…
Reference in New Issue
Block a user