MXS-2219 Differentiate between READY and ERROR with http::Async

An async http operation that has not been initiated is READY,
while an operation that cannot be initated is ERRORed.
This commit is contained in:
Johan Wikman
2018-12-20 15:14:28 +02:00
parent 64cf3327cc
commit 839b9b781d

View File

@ -172,21 +172,22 @@ struct Context
Errbuf * pErrbuf; Errbuf * pErrbuf;
}; };
class ErrorImp : public Async::Imp class ReadyImp : public Async::Imp
{ {
public: public:
ErrorImp() ReadyImp(Async::status_t status = Async::READY)
: m_status(status)
{ {
} }
Async::status_t status() const Async::status_t status() const
{ {
return Async::ERROR; return m_status;
} }
Async::status_t perform(long timeout_ms) Async::status_t perform(long timeout_ms)
{ {
return Async::ERROR; return m_status;
} }
long wait_no_more_than() const long wait_no_more_than() const
@ -200,6 +201,7 @@ public:
} }
private: private:
Async::status_t m_status;
vector<Result> m_results; vector<Result> m_results;
}; };
@ -485,7 +487,7 @@ Async::Imp::~Imp()
} }
Async::Async() Async::Async()
: m_sImp(std::make_shared<ErrorImp>()) : m_sImp(std::make_shared<ReadyImp>())
{ {
} }
@ -507,7 +509,7 @@ Async get_async(const std::vector<std::string>& urls,
} }
else else
{ {
sImp = std::make_shared<ErrorImp>(); sImp = std::make_shared<ReadyImp>(Async::ERROR);
} }
return Async(sImp); return Async(sImp);