Commit 8e34663b authored by Mathieu Stefani's avatar Mathieu Stefani

Bunch of fixes for gcc < 4.9

parent 6362142f
...@@ -758,10 +758,23 @@ namespace Async { ...@@ -758,10 +758,23 @@ namespace Async {
> >
> >
Promise<Results> whenAll(Args&& ...args) { Promise<Results> whenAll(Args&& ...args) {
return Promise<Results>([&](Resolver& resolver, Rejection& rejection) { // As ugly as it looks, this is needed to bypass a bug of gcc < 4.9
Impl::WhenAll impl(resolver, rejection); // whereby template parameters pack inside a lambda expression are not
impl(std::forward<Args>(args)...); // captured correctly and can not be expanded inside the lambda.
Resolver* resolve;
Rejection* reject;
Promise<Results> promise([&](Resolver& resolver, Rejection& rejection) {
resolve = &resolver;
reject = &rejection;
}); });
Impl::WhenAll impl(*resolve, *reject);
// So we capture everything we need inside the lambda and then call the
// implementation and expand the parameters pack here
impl(std::forward<Args>(args)...);
return promise;
} }
template< template<
......
...@@ -350,10 +350,25 @@ Request::query() const { ...@@ -350,10 +350,25 @@ Request::query() const {
Response::Response() Response::Response()
: Message() : Message()
, bufSize(Const::MaxBuffer << 1) , bufSize_(Const::MaxBuffer << 1)
, buffer_(new char[bufSize]) , buffer_(new char[bufSize_])
{ } { }
Response::Response(Response&& other)
: peer_(other.peer_)
, bufSize_(other.bufSize_)
, buffer_(std::move(other.buffer_))
{ }
Response&
Response::operator=(Response&& other) {
peer_ = other.peer_;
bufSize_ = other.bufSize_;
buffer_ = std::move(other.buffer_);
return *this;
}
void void
Response::associatePeer(const std::shared_ptr<Tcp::Peer>& peer) Response::associatePeer(const std::shared_ptr<Tcp::Peer>& peer)
{ {
...@@ -373,7 +388,7 @@ Response::send(Code code, const std::string& body, const Mime::MediaType& mime) ...@@ -373,7 +388,7 @@ Response::send(Code code, const std::string& body, const Mime::MediaType& mime)
{ {
char *beg = buffer_.get(); char *beg = buffer_.get();
Io::OutArrayBuf obuf(beg, beg + bufSize, Io::Init::ZeroOut); Io::OutArrayBuf obuf(beg, beg + bufSize_, Io::Init::ZeroOut);
std::ostream stream(&obuf); std::ostream stream(&obuf);
#define OUT(...) \ #define OUT(...) \
......
...@@ -89,8 +89,11 @@ public: ...@@ -89,8 +89,11 @@ public:
Response(const Response& other) = delete; Response(const Response& other) = delete;
Response& operator=(const Response& other) = delete; Response& operator=(const Response& other) = delete;
Response(Response&& other) = default; // C++11: std::weak_ptr move constructor is C++14 only so the default
Response& operator=(Response&& other) = default; // version of move constructor / assignement operator does not work and we
// have to define it ourself
Response(Response&& other);
Response& operator=(Response&& other);
Header::Collection& headers(); Header::Collection& headers();
const Header::Collection& headers() const; const Header::Collection& headers() const;
...@@ -108,7 +111,7 @@ private: ...@@ -108,7 +111,7 @@ private:
void associatePeer(const std::shared_ptr<Tcp::Peer>& peer); void associatePeer(const std::shared_ptr<Tcp::Peer>& peer);
std::weak_ptr<Tcp::Peer> peer_; std::weak_ptr<Tcp::Peer> peer_;
size_t bufSize; size_t bufSize_;
std::unique_ptr<char[]> buffer_; std::unique_ptr<char[]> buffer_;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment