mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-03 01:15:53 +00:00
Added AbstractHandler, WrapHandler. HTTPClient Fixes.
This commit is contained in:
706
modules/beast_asio/async/AbstractHandler.h
Normal file
706
modules/beast_asio/async/AbstractHandler.h
Normal file
@@ -0,0 +1,706 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef BEAST_ASIO_ABSTRACTHANDLER_H_INCLUDED
|
||||
#define BEAST_ASIO_ABSTRACTHANDLER_H_INCLUDED
|
||||
|
||||
namespace beast {
|
||||
|
||||
namespace detail {
|
||||
|
||||
struct AbstractHandlerCallBase : SharedObject
|
||||
{
|
||||
//typedef SharedFunction <void(void),
|
||||
// AbstractHandlerAllocator <char> > invoked_type;
|
||||
|
||||
typedef SharedFunction <void(void)> invoked_type;
|
||||
|
||||
virtual void* allocate (std::size_t size) = 0;
|
||||
virtual void deallocate (void* p, std::size_t size) = 0;
|
||||
virtual bool is_continuation () = 0;
|
||||
virtual void invoke (invoked_type& invoked) = 0;
|
||||
|
||||
template <typename Function>
|
||||
void invoke (BEAST_MOVE_ARG(Function) f)
|
||||
{
|
||||
invoked_type invoked (BEAST_MOVE_CAST(Function)(f)
|
||||
//, AbstractHandlerAllocator<char>(this)
|
||||
);
|
||||
invoke (invoked);
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
template <typename T>
|
||||
struct AbstractHandlerAllocator
|
||||
{
|
||||
typedef T value_type;
|
||||
typedef T* pointer;
|
||||
typedef T& reference;
|
||||
typedef T const* const_pointer;
|
||||
typedef T const& const_reference;
|
||||
typedef std::size_t size_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
|
||||
AbstractHandlerAllocator (AbstractHandler* handler) noexcept
|
||||
: m_ptr (handler)
|
||||
{
|
||||
}
|
||||
|
||||
AbstractHandlerAllocator (SharedPtr <AbstractHandler> const& ptr) noexcept
|
||||
: m_ptr (ptr)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename U>
|
||||
AbstractHandlerAllocator (AbstractHandlerAllocator <U> const& other)
|
||||
: m_ptr (other.m_ptr)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename U>
|
||||
struct rebind
|
||||
{
|
||||
typedef AbstractHandlerAllocator <U> other;
|
||||
};
|
||||
|
||||
pointer address (reference x) const
|
||||
{
|
||||
return &x;
|
||||
}
|
||||
|
||||
const_pointer address (const_reference x) const
|
||||
{
|
||||
return &x;
|
||||
}
|
||||
|
||||
pointer allocate (size_type n) const
|
||||
{
|
||||
size_type const bytes = n * sizeof (value_type);
|
||||
return static_cast <pointer> (m_ptr->allocate (bytes));
|
||||
}
|
||||
|
||||
void deallocate (pointer p, size_type n) const
|
||||
{
|
||||
size_type const bytes = n * sizeof (value_type);
|
||||
m_ptr->deallocate (p, bytes);
|
||||
}
|
||||
|
||||
size_type max_size () const noexcept
|
||||
{
|
||||
return std::numeric_limits <size_type>::max () / sizeof (value_type);
|
||||
}
|
||||
|
||||
void construct (pointer p, const_reference val) const
|
||||
{
|
||||
new ((void *)p) value_type (val);
|
||||
}
|
||||
|
||||
void destroy (pointer p) const
|
||||
{
|
||||
p->~value_type ();
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename>
|
||||
friend struct AbstractHandlerAllocator;
|
||||
friend class AbstractHandler;
|
||||
|
||||
SharedPtr <AbstractHandler> m_ptr;
|
||||
};
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
/** A reference counted, abstract completion handler. */
|
||||
template <typename Signature, class Allocator = std::allocator <char> >
|
||||
class AbstractHandler;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// arity 0
|
||||
template <class R, class A>
|
||||
struct AbstractHandler <R (void), A>
|
||||
{
|
||||
typedef R result_type;
|
||||
struct Call : detail::AbstractHandlerCallBase
|
||||
{ virtual R operator() () = 0; };
|
||||
|
||||
template <typename H>
|
||||
struct CallType : public Call
|
||||
{
|
||||
typedef typename A:: template rebind <CallType <H> >::other Allocator;
|
||||
CallType (BEAST_MOVE_ARG(H) h, A a = A ())
|
||||
: m_h (BEAST_MOVE_CAST(H)(h)), m_alloc (a)
|
||||
{ }
|
||||
R operator()()
|
||||
{ return (m_h)(); }
|
||||
R operator()() const
|
||||
{ return (m_h)(); }
|
||||
void* allocate (std::size_t size)
|
||||
{ return boost_asio_handler_alloc_helpers::allocate(size, m_h); }
|
||||
void deallocate (void* pointer, std::size_t size)
|
||||
{ boost_asio_handler_alloc_helpers::deallocate( pointer, size, m_h); }
|
||||
bool is_continuation ()
|
||||
#if BEAST_ASIO_HAS_CONTINUATION_HOOKS
|
||||
{ return boost_asio_handler_cont_helpers::is_continuation(m_h); }
|
||||
#else
|
||||
{ return false; }
|
||||
#endif
|
||||
void invoke (invoked_type& invoked)
|
||||
{ boost_asio_handler_invoke_helpers::invoke <invoked_type, H> (invoked, m_h); }
|
||||
private:
|
||||
H m_h;
|
||||
Allocator m_alloc;
|
||||
};
|
||||
|
||||
template <typename H>
|
||||
AbstractHandler (BEAST_MOVE_ARG(H) h, A a = A ())
|
||||
: m_call (new (
|
||||
typename A:: template rebind <CallType <H> >::other (a)
|
||||
.allocate (1)) CallType <H> (BEAST_MOVE_CAST(H)(h), a))
|
||||
{ }
|
||||
R operator() ()
|
||||
{ return (*m_call)(); }
|
||||
R operator() () const
|
||||
{ return (*m_call)(); }
|
||||
void* allocate (std::size_t size) const { return m_call->allocate(size); }
|
||||
void deallocate (void* pointer, std::size_t size) const { m_call->deallocate(pointer,size); }
|
||||
bool is_continuation () const { return m_call->is_continuation(); }
|
||||
template <typename Function>
|
||||
void invoke (Function& function) const
|
||||
{
|
||||
m_call->invoke(function);
|
||||
}
|
||||
template <typename Function>
|
||||
void invoke (Function const& function) const
|
||||
{
|
||||
m_call->invoke(function);
|
||||
}
|
||||
|
||||
private:
|
||||
SharedPtr <Call> m_call;
|
||||
};
|
||||
|
||||
template <class R, class A>
|
||||
void* asio_handler_allocate (std::size_t size,
|
||||
AbstractHandler <R (void), A>* handler)
|
||||
{
|
||||
return handler->allocate (size);
|
||||
}
|
||||
|
||||
template <class R, class A>
|
||||
void asio_handler_deallocate (void* pointer, std::size_t size,
|
||||
AbstractHandler <R (void), A>* handler)
|
||||
{
|
||||
handler->deallocate (pointer, size);
|
||||
}
|
||||
|
||||
template <class R, class A>
|
||||
bool asio_handler_is_continuation(
|
||||
AbstractHandler <R (void), A>* handler)
|
||||
{
|
||||
return handler->is_continuation();
|
||||
}
|
||||
|
||||
template <typename Function, class R, class A>
|
||||
void asio_handler_invoke (BEAST_MOVE_ARG(Function) function,
|
||||
AbstractHandler <R (void), A>* handler)
|
||||
{
|
||||
handler->invoke (BEAST_MOVE_CAST(Function)(function));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// arity 1
|
||||
template <class R, class P1, class A>
|
||||
struct AbstractHandler <R (P1), A>
|
||||
{
|
||||
typedef R result_type;
|
||||
struct Call : detail::AbstractHandlerCallBase
|
||||
{ virtual R operator() (P1) = 0; };
|
||||
|
||||
template <typename H>
|
||||
struct CallType : public Call
|
||||
{
|
||||
typedef typename A:: template rebind <CallType <H> >::other Allocator;
|
||||
CallType (H h, A a = A ())
|
||||
: m_h (h)
|
||||
, m_alloc (a)
|
||||
{
|
||||
}
|
||||
|
||||
R operator()(P1 p1)
|
||||
{ return (m_h)(p1); }
|
||||
R operator()(P1 p1) const
|
||||
{ return (m_h)(p1); }
|
||||
void* allocate (std::size_t size)
|
||||
{ return boost_asio_handler_alloc_helpers::allocate(size, m_h); }
|
||||
void deallocate (void* pointer, std::size_t size)
|
||||
{ boost_asio_handler_alloc_helpers::deallocate( pointer, size, m_h); }
|
||||
bool is_continuation ()
|
||||
#if BEAST_ASIO_HAS_CONTINUATION_HOOKS
|
||||
{ return boost_asio_handler_cont_helpers::is_continuation(m_h); }
|
||||
#else
|
||||
{ return false; }
|
||||
#endif
|
||||
void invoke (invoked_type& invoked)
|
||||
{ boost_asio_handler_invoke_helpers::invoke <invoked_type, H> (invoked, m_h); }
|
||||
private:
|
||||
H m_h;
|
||||
Allocator m_alloc;
|
||||
};
|
||||
|
||||
template <typename H>
|
||||
AbstractHandler (H h, A a = A ())
|
||||
: m_call (new (
|
||||
typename A:: template rebind <CallType <H> >::other (a)
|
||||
.allocate (1)) CallType <H> (h, a))
|
||||
{
|
||||
}
|
||||
|
||||
R operator() (P1 p1)
|
||||
{ return (*m_call)(p1); }
|
||||
R operator() (P1 p1) const
|
||||
{ return (*m_call)(p1); }
|
||||
void* allocate (std::size_t size) const { return m_call->allocate(size); }
|
||||
void deallocate (void* pointer, std::size_t size) const { m_call->deallocate(pointer,size); }
|
||||
bool is_continuation () const { return m_call->is_continuation(); }
|
||||
template <typename Function>
|
||||
void invoke (Function& function) const
|
||||
{
|
||||
m_call->invoke(function);
|
||||
}
|
||||
template <typename Function>
|
||||
void invoke (Function const& function) const
|
||||
{
|
||||
m_call->invoke(function);
|
||||
}
|
||||
|
||||
private:
|
||||
SharedPtr <Call> m_call;
|
||||
};
|
||||
|
||||
template <class R, class P1, class A>
|
||||
void* asio_handler_allocate (std::size_t size,
|
||||
AbstractHandler <R (P1), A>* handler)
|
||||
{
|
||||
return handler->allocate (size);
|
||||
}
|
||||
|
||||
template <class R, class P1, class A>
|
||||
void asio_handler_deallocate (void* pointer, std::size_t size,
|
||||
AbstractHandler <R (P1), A>* handler)
|
||||
{
|
||||
handler->deallocate (pointer, size);
|
||||
}
|
||||
|
||||
template <class R, class P1, class A>
|
||||
bool asio_handler_is_continuation(
|
||||
AbstractHandler <R (P1), A>* handler)
|
||||
{
|
||||
return handler->is_continuation();
|
||||
}
|
||||
|
||||
template <typename Function, class R, class P1, class A>
|
||||
void asio_handler_invoke (BEAST_MOVE_ARG(Function) function,
|
||||
AbstractHandler <R (P1), A>* handler)
|
||||
{
|
||||
handler->invoke (BEAST_MOVE_CAST(Function)(function));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// arity 2
|
||||
template <class R, class P1, class P2, class A>
|
||||
struct AbstractHandler <R (P1, P2), A>
|
||||
{
|
||||
typedef R result_type;
|
||||
struct Call : detail::AbstractHandlerCallBase
|
||||
{ virtual R operator() (P1, P2) = 0; };
|
||||
|
||||
template <typename H>
|
||||
struct CallType : public Call
|
||||
{
|
||||
typedef typename A:: template rebind <CallType <H> >::other Allocator;
|
||||
CallType (BEAST_MOVE_ARG(H) h, A a = A ())
|
||||
: m_h (BEAST_MOVE_CAST(H)(h)), m_alloc (a)
|
||||
{ }
|
||||
R operator()(P1 p1, P2 p2)
|
||||
{ return (m_h)(p1, p2); }
|
||||
R operator()(P1 p1, P2 p2) const
|
||||
{ return (m_h)(p1, p2); }
|
||||
void* allocate (std::size_t size)
|
||||
{ return boost_asio_handler_alloc_helpers::allocate(size, m_h); }
|
||||
void deallocate (void* pointer, std::size_t size)
|
||||
{ boost_asio_handler_alloc_helpers::deallocate( pointer, size, m_h); }
|
||||
bool is_continuation ()
|
||||
#if BEAST_ASIO_HAS_CONTINUATION_HOOKS
|
||||
{ return boost_asio_handler_cont_helpers::is_continuation(m_h); }
|
||||
#else
|
||||
{ return false; }
|
||||
#endif
|
||||
void invoke (invoked_type& invoked)
|
||||
{ boost_asio_handler_invoke_helpers::invoke <invoked_type, H> (invoked, m_h); }
|
||||
private:
|
||||
H m_h;
|
||||
Allocator m_alloc;
|
||||
};
|
||||
|
||||
template <typename H>
|
||||
AbstractHandler (BEAST_MOVE_ARG(H) h, A a = A ())
|
||||
: m_call (new (
|
||||
typename A:: template rebind <CallType <H> >::other (a)
|
||||
.allocate (1)) CallType <H> (BEAST_MOVE_CAST(H)(h), a))
|
||||
{ }
|
||||
R operator() (P1 p1, P2 p2)
|
||||
{ return (*m_call)(p1, p2); }
|
||||
R operator() (P1 p1, P2 p2) const
|
||||
{ return (*m_call)(p1, p2); }
|
||||
void* allocate (std::size_t size) const { return m_call->allocate(size); }
|
||||
void deallocate (void* pointer, std::size_t size) const { m_call->deallocate(pointer,size); }
|
||||
bool is_continuation () const { return m_call->is_continuation(); }
|
||||
template <typename Function>
|
||||
void invoke (Function& function) const
|
||||
{
|
||||
m_call->invoke(function);
|
||||
}
|
||||
template <typename Function>
|
||||
void invoke (Function const& function) const
|
||||
{
|
||||
m_call->invoke(function);
|
||||
}
|
||||
|
||||
private:
|
||||
SharedPtr <Call> m_call;
|
||||
};
|
||||
|
||||
template <class R, class P1, class P2, class A>
|
||||
void* asio_handler_allocate (std::size_t size,
|
||||
AbstractHandler <R (P1, P2), A>* handler)
|
||||
{
|
||||
return handler->allocate (size);
|
||||
}
|
||||
|
||||
template <class R, class P1, class P2, class A>
|
||||
void asio_handler_deallocate (void* pointer, std::size_t size,
|
||||
AbstractHandler <R (P1, P2), A>* handler)
|
||||
{
|
||||
handler->deallocate (pointer, size);
|
||||
}
|
||||
|
||||
template <class R, class P1, class P2, class A>
|
||||
bool asio_handler_is_continuation(
|
||||
AbstractHandler <R (P1, P2), A>* handler)
|
||||
{
|
||||
return handler->is_continuation();
|
||||
}
|
||||
|
||||
template <typename Function, class R, class P1, class P2, class A>
|
||||
void asio_handler_invoke (BEAST_MOVE_ARG(Function) function,
|
||||
AbstractHandler <R (P1, P2), A>* handler)
|
||||
{
|
||||
handler->invoke (BEAST_MOVE_CAST(Function)(function));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// arity 3
|
||||
template <class R, class P1, class P2, class P3, class A>
|
||||
struct AbstractHandler <R (P1, P2, P3), A>
|
||||
{
|
||||
typedef R result_type;
|
||||
struct Call : detail::AbstractHandlerCallBase
|
||||
{ virtual R operator() (P1, P2, P3) = 0; };
|
||||
|
||||
template <typename H>
|
||||
struct CallType : public Call
|
||||
{
|
||||
typedef typename A:: template rebind <CallType <H> >::other Allocator;
|
||||
CallType (BEAST_MOVE_ARG(H) h, A a = A ())
|
||||
: m_h (BEAST_MOVE_CAST(H)(h)), m_alloc (a)
|
||||
{ }
|
||||
R operator()(P1 p1, P2 p2, P3 p3)
|
||||
{ return (m_h)(p1, p2, p3); }
|
||||
R operator()(P1 p1, P2 p2, P3 p3) const
|
||||
{ return (m_h)(p1, p2, p3); }
|
||||
void* allocate (std::size_t size)
|
||||
{ return boost_asio_handler_alloc_helpers::allocate(size, m_h); }
|
||||
void deallocate (void* pointer, std::size_t size)
|
||||
{ boost_asio_handler_alloc_helpers::deallocate( pointer, size, m_h); }
|
||||
bool is_continuation ()
|
||||
#if BEAST_ASIO_HAS_CONTINUATION_HOOKS
|
||||
{ return boost_asio_handler_cont_helpers::is_continuation(m_h); }
|
||||
#else
|
||||
{ return false; }
|
||||
#endif
|
||||
void invoke (invoked_type& invoked)
|
||||
{ boost_asio_handler_invoke_helpers::invoke <invoked_type, H> (invoked, m_h); }
|
||||
private:
|
||||
H m_h;
|
||||
Allocator m_alloc;
|
||||
};
|
||||
|
||||
template <typename H>
|
||||
AbstractHandler (BEAST_MOVE_ARG(H) h, A a = A ())
|
||||
: m_call (new (
|
||||
typename A:: template rebind <CallType <H> >::other (a)
|
||||
.allocate (1)) CallType <H> (BEAST_MOVE_CAST(H)(h), a))
|
||||
{ }
|
||||
R operator() (P1 p1, P2 p2, P3 p3)
|
||||
{ return (*m_call)(p1, p2, p3); }
|
||||
R operator() (P1 p1, P2 p2, P3 p3) const
|
||||
{ return (*m_call)(p1, p2, p3); }
|
||||
void* allocate (std::size_t size) const { return m_call->allocate(size); }
|
||||
void deallocate (void* pointer, std::size_t size) const { m_call->deallocate(pointer,size); }
|
||||
bool is_continuation () const { return m_call->is_continuation(); }
|
||||
template <typename Function>
|
||||
void invoke (Function& function) const
|
||||
{
|
||||
m_call->invoke(function);
|
||||
}
|
||||
template <typename Function>
|
||||
void invoke (Function const& function) const
|
||||
{
|
||||
m_call->invoke(function);
|
||||
}
|
||||
|
||||
private:
|
||||
SharedPtr <Call> m_call;
|
||||
};
|
||||
|
||||
template <class R, class P1, class P2, class P3, class A>
|
||||
void* asio_handler_allocate (std::size_t size,
|
||||
AbstractHandler <R (P1, P2, P3), A>* handler)
|
||||
{
|
||||
return handler->allocate (size);
|
||||
}
|
||||
|
||||
template <class R, class P1, class P2, class P3, class A>
|
||||
void asio_handler_deallocate (void* pointer, std::size_t size,
|
||||
AbstractHandler <R (P1, P2, P3), A>* handler)
|
||||
{
|
||||
handler->deallocate (pointer, size);
|
||||
}
|
||||
|
||||
template <class R, class P1, class P2, class P3, class A>
|
||||
bool asio_handler_is_continuation(
|
||||
AbstractHandler <R (P1, P2, P3), A>* handler)
|
||||
{
|
||||
return handler->is_continuation();
|
||||
}
|
||||
|
||||
template <typename Function, class R, class P1, class P2, class P3, class A>
|
||||
void asio_handler_invoke (BEAST_MOVE_ARG(Function) function,
|
||||
AbstractHandler <R (P1, P2, P3), A>* handler)
|
||||
{
|
||||
handler->invoke (BEAST_MOVE_CAST(Function)(function));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// arity 4
|
||||
template <class R, class P1, class P2, class P3, class P4, class A>
|
||||
struct AbstractHandler <R (P1, P2, P3, P4), A>
|
||||
{
|
||||
typedef R result_type;
|
||||
struct Call : detail::AbstractHandlerCallBase
|
||||
{ virtual R operator() (P1, P2, P3, P4) = 0; };
|
||||
|
||||
template <typename H>
|
||||
struct CallType : public Call
|
||||
{
|
||||
typedef typename A:: template rebind <CallType <H> >::other Allocator;
|
||||
CallType (BEAST_MOVE_ARG(H) h, A a = A ())
|
||||
: m_h (BEAST_MOVE_CAST(H)(h)), m_alloc (a)
|
||||
{ }
|
||||
R operator()(P1 p1, P2 p2, P3 p3, P4 p4)
|
||||
{ return (m_h)(p1, p2, p3, p4); }
|
||||
R operator()(P1 p1, P2 p2, P3 p3, P4 p4) const
|
||||
{ return (m_h)(p1, p2, p3, p4); }
|
||||
void* allocate (std::size_t size)
|
||||
{ return boost_asio_handler_alloc_helpers::allocate(size, m_h); }
|
||||
void deallocate (void* pointer, std::size_t size)
|
||||
{ boost_asio_handler_alloc_helpers::deallocate( pointer, size, m_h); }
|
||||
bool is_continuation ()
|
||||
#if BEAST_ASIO_HAS_CONTINUATION_HOOKS
|
||||
{ return boost_asio_handler_cont_helpers::is_continuation(m_h); }
|
||||
#else
|
||||
{ return false; }
|
||||
#endif
|
||||
void invoke (invoked_type& invoked)
|
||||
{ boost_asio_handler_invoke_helpers::invoke <invoked_type, H> (invoked, m_h); }
|
||||
private:
|
||||
H m_h;
|
||||
Allocator m_alloc;
|
||||
};
|
||||
|
||||
template <typename H>
|
||||
AbstractHandler (BEAST_MOVE_ARG(H) h, A a = A ())
|
||||
: m_call (new (
|
||||
typename A:: template rebind <CallType <H> >::other (a)
|
||||
.allocate (1)) CallType <H> (BEAST_MOVE_CAST(H)(h), a))
|
||||
{ }
|
||||
R operator() (P1 p1, P2 p2, P3 p3, P4 p4)
|
||||
{ return (*m_call)(p1, p2, p3, p4); }
|
||||
R operator() (P1 p1, P2 p2, P3 p3, P4 p4) const
|
||||
{ return (*m_call)(p1, p2, p3, p4); }
|
||||
void* allocate (std::size_t size) const { return m_call->allocate(size); }
|
||||
void deallocate (void* pointer, std::size_t size) const { m_call->deallocate(pointer,size); }
|
||||
bool is_continuation () const { return m_call->is_continuation(); }
|
||||
template <typename Function>
|
||||
void invoke (Function& function) const
|
||||
{
|
||||
m_call->invoke(function);
|
||||
}
|
||||
template <typename Function>
|
||||
void invoke (Function const& function) const
|
||||
{
|
||||
m_call->invoke(function);
|
||||
}
|
||||
|
||||
private:
|
||||
SharedPtr <Call> m_call;
|
||||
};
|
||||
|
||||
template <class R, class P1, class P2, class P3, class P4, class A>
|
||||
void* asio_handler_allocate (std::size_t size,
|
||||
AbstractHandler <R (P1, P2, P3, P4), A>* handler)
|
||||
{
|
||||
return handler->allocate (size);
|
||||
}
|
||||
|
||||
template <class R, class P1, class P2, class P3, class P4, class A>
|
||||
void asio_handler_deallocate (void* pointer, std::size_t size,
|
||||
AbstractHandler <R (P1, P2, P3, P4), A>* handler)
|
||||
{
|
||||
handler->deallocate (pointer, size);
|
||||
}
|
||||
|
||||
template <class R, class P1, class P2, class P3, class P4, class A>
|
||||
bool asio_handler_is_continuation(
|
||||
AbstractHandler <R (P1, P2, P3, P4), A>* handler)
|
||||
{
|
||||
return handler->is_continuation();
|
||||
}
|
||||
|
||||
template <typename Function, class R, class P1, class P2, class P3, class P4, class A>
|
||||
void asio_handler_invoke (BEAST_MOVE_ARG(Function) function,
|
||||
AbstractHandler <R (P1, P2, P3, P4), A>* handler)
|
||||
{
|
||||
handler->invoke (BEAST_MOVE_CAST(Function)(function));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// arity 5
|
||||
template <class R, class P1, class P2, class P3, class P4, class P5, class A>
|
||||
struct AbstractHandler <R (P1, P2, P3, P4, P5), A>
|
||||
{
|
||||
typedef R result_type;
|
||||
struct Call : detail::AbstractHandlerCallBase
|
||||
{ virtual R operator() (P1, P2, P3, P4, P5) = 0; };
|
||||
|
||||
template <typename H>
|
||||
struct CallType : public Call
|
||||
{
|
||||
typedef typename A:: template rebind <CallType <H> >::other Allocator;
|
||||
CallType (BEAST_MOVE_ARG(H) h, A a = A ())
|
||||
: m_h (BEAST_MOVE_CAST(H)(h)), m_alloc (a)
|
||||
{ }
|
||||
R operator()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5)
|
||||
{ return (m_h)(p1, p2, p3, p4, p5); }
|
||||
R operator()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) const
|
||||
{ return (m_h)(p1, p2, p3, p4, p5); }
|
||||
void* allocate (std::size_t size)
|
||||
{ return boost_asio_handler_alloc_helpers::allocate(size, m_h); }
|
||||
void deallocate (void* pointer, std::size_t size)
|
||||
{ boost_asio_handler_alloc_helpers::deallocate( pointer, size, m_h); }
|
||||
bool is_continuation ()
|
||||
#if BEAST_ASIO_HAS_CONTINUATION_HOOKS
|
||||
{ return boost_asio_handler_cont_helpers::is_continuation(m_h); }
|
||||
#else
|
||||
{ return false; }
|
||||
#endif
|
||||
void invoke (invoked_type& invoked)
|
||||
{ boost_asio_handler_invoke_helpers::invoke <invoked_type, H> (invoked, m_h); }
|
||||
private:
|
||||
H m_h;
|
||||
Allocator m_alloc;
|
||||
};
|
||||
|
||||
template <typename H>
|
||||
AbstractHandler (BEAST_MOVE_ARG(H) h, A a = A ())
|
||||
: m_call (new (
|
||||
typename A:: template rebind <CallType <H> >::other (a)
|
||||
.allocate (1)) CallType <H> (BEAST_MOVE_CAST(H)(h), a))
|
||||
{ }
|
||||
R operator() (P1 p1, P2 p2, P3 p3, P4 p4, P5 p5)
|
||||
{ return (*m_call)(p1, p2, p3, p4, p5); }
|
||||
R operator() (P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) const
|
||||
{ return (*m_call)(p1, p2, p3, p4, p5); }
|
||||
void* allocate (std::size_t size) const { return m_call->allocate(size); }
|
||||
void deallocate (void* pointer, std::size_t size) const { m_call->deallocate(pointer,size); }
|
||||
bool is_continuation () const { return m_call->is_continuation(); }
|
||||
template <typename Function>
|
||||
void invoke (Function& function) const
|
||||
{
|
||||
m_call->invoke(function);
|
||||
}
|
||||
template <typename Function>
|
||||
void invoke (Function const& function) const
|
||||
{
|
||||
m_call->invoke(function);
|
||||
}
|
||||
|
||||
private:
|
||||
SharedPtr <Call> m_call;
|
||||
};
|
||||
|
||||
template <class R, class P1, class P2, class P3, class P4, class P5, class A>
|
||||
void* asio_handler_allocate (std::size_t size,
|
||||
AbstractHandler <R (P1, P2, P3, P4, P5), A>* handler)
|
||||
{
|
||||
return handler->allocate (size);
|
||||
}
|
||||
|
||||
template <class R, class P1, class P2, class P3, class P4, class P5, class A>
|
||||
void asio_handler_deallocate (void* pointer, std::size_t size,
|
||||
AbstractHandler <R (P1, P2, P3, P4, P5), A>* handler)
|
||||
{
|
||||
handler->deallocate (pointer, size);
|
||||
}
|
||||
|
||||
template <class R, class P1, class P2, class P3, class P4, class P5, class A>
|
||||
bool asio_handler_is_continuation(
|
||||
AbstractHandler <R (P1, P2, P3, P4, P5), A>* handler)
|
||||
{
|
||||
return handler->is_continuation();
|
||||
}
|
||||
|
||||
template <typename Function, class R, class P1, class P2, class P3, class P4, class P5, class A>
|
||||
void asio_handler_invoke (BEAST_MOVE_ARG(Function) function,
|
||||
AbstractHandler <R (P1, P2, P3, P4, P5), A>* handler)
|
||||
{
|
||||
handler->invoke (BEAST_MOVE_CAST(Function)(function));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -45,11 +45,9 @@ class SharedHandler : public SharedObject
|
||||
{
|
||||
protected:
|
||||
typedef boost::system::error_code error_code;
|
||||
#if 0
|
||||
typedef boost::function <void(void)> invoked_type;
|
||||
#else
|
||||
typedef SharedFunction <void(void), SharedHandlerAllocator <char> > invoked_type;
|
||||
#endif
|
||||
|
||||
typedef SharedFunction <void(void),
|
||||
SharedHandlerAllocator <char> > invoked_type;
|
||||
|
||||
SharedHandler () noexcept { }
|
||||
|
||||
@@ -65,9 +63,6 @@ public:
|
||||
|
||||
template <typename Function>
|
||||
void invoke (BOOST_ASIO_MOVE_ARG(Function) f)
|
||||
#if 0
|
||||
;
|
||||
#else
|
||||
{
|
||||
// The allocator will hold a reference to the SharedHandler
|
||||
// so that we can safely destroy the function object.
|
||||
@@ -75,7 +70,6 @@ public:
|
||||
SharedHandlerAllocator <char> (this));
|
||||
invoke (invoked);
|
||||
}
|
||||
#endif
|
||||
|
||||
virtual void invoke (invoked_type& invoked) = 0;
|
||||
virtual void* allocate (std::size_t size) = 0;
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
|
||||
@see isNull, isNotNull
|
||||
*/
|
||||
inline SharedHandlerPtr () noexcept
|
||||
inline SharedHandlerPtr ()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -55,15 +55,14 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
/** Construct a reference from an existing container.
|
||||
*/
|
||||
inline SharedHandlerPtr (SharedHandlerPtr const& other) noexcept
|
||||
/** Construct a reference from an existing container. */
|
||||
inline SharedHandlerPtr (SharedHandlerPtr const& other)
|
||||
: m_ptr (other.m_ptr)
|
||||
{
|
||||
}
|
||||
|
||||
/** Assign a reference from an existing container. */
|
||||
inline SharedHandlerPtr& operator= (SharedHandlerPtr const& other) noexcept
|
||||
inline SharedHandlerPtr& operator= (SharedHandlerPtr const& other)
|
||||
{
|
||||
m_ptr = other.m_ptr;
|
||||
return *this;
|
||||
@@ -73,7 +72,7 @@ public:
|
||||
/** Move-construct a reference from an existing container.
|
||||
The other container is set to a null handler.
|
||||
*/
|
||||
inline SharedHandlerPtr (SharedHandlerPtr&& other) noexcept
|
||||
inline SharedHandlerPtr (SharedHandlerPtr&& other)
|
||||
: m_ptr (other.m_ptr)
|
||||
{
|
||||
other.m_ptr = nullptr;
|
||||
@@ -82,7 +81,7 @@ public:
|
||||
/** Move-assign a reference from an existing container.
|
||||
The other container is set to a null handler.
|
||||
*/
|
||||
inline SharedHandlerPtr& operator= (SharedHandlerPtr&& other) noexcept
|
||||
inline SharedHandlerPtr& operator= (SharedHandlerPtr&& other)
|
||||
{
|
||||
m_ptr = other.m_ptr;
|
||||
other.m_ptr = nullptr;
|
||||
@@ -91,13 +90,13 @@ public:
|
||||
#endif
|
||||
|
||||
/** Returns true if the handler is a null handler. */
|
||||
inline bool isNull () const noexcept
|
||||
inline bool isNull () const
|
||||
{
|
||||
return m_ptr == nullptr;
|
||||
}
|
||||
|
||||
/** Returns true if the handler is not a null handler. */
|
||||
inline bool isNotNull () const noexcept
|
||||
inline bool isNotNull () const
|
||||
{
|
||||
return m_ptr != nullptr;
|
||||
}
|
||||
@@ -105,7 +104,7 @@ public:
|
||||
/** Dereference the container.
|
||||
This returns a reference to the underlying SharedHandler object.
|
||||
*/
|
||||
inline SharedHandler& operator* () const noexcept
|
||||
inline SharedHandler& operator* () const
|
||||
{
|
||||
return *m_ptr;
|
||||
}
|
||||
@@ -113,7 +112,7 @@ public:
|
||||
/** SharedHandler member access.
|
||||
This lets you call functions directly on the SharedHandler.
|
||||
*/
|
||||
inline SharedHandler* operator-> () const noexcept
|
||||
inline SharedHandler* operator-> () const
|
||||
{
|
||||
return m_ptr.get ();
|
||||
}
|
||||
@@ -132,7 +131,7 @@ public:
|
||||
|
||||
@endcode
|
||||
*/
|
||||
inline SharedHandler* get () const noexcept
|
||||
inline SharedHandler* get () const
|
||||
{
|
||||
return m_ptr.get ();
|
||||
}
|
||||
@@ -144,7 +143,7 @@ public:
|
||||
{
|
||||
(*m_ptr)();
|
||||
}
|
||||
|
||||
|
||||
/** Invoke the SharedHandler with signature void(error_code)
|
||||
Normally this is called by a dispatcher, you shouldn't call it directly.
|
||||
*/
|
||||
@@ -180,7 +179,7 @@ private:
|
||||
//
|
||||
|
||||
template <class Function>
|
||||
inline void asio_handler_invoke (BOOST_ASIO_MOVE_ARG(Function) f, SharedHandlerPtr* ptr)
|
||||
void asio_handler_invoke (BOOST_ASIO_MOVE_ARG(Function) f, SharedHandlerPtr* ptr)
|
||||
{
|
||||
boost_asio_handler_invoke_helpers::
|
||||
invoke <Function, SharedHandler>
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#define BEAST_ASIO_ASYNC_SHAREDHANDLERTYPE_H_INCLUDED
|
||||
|
||||
/** An instance of SharedHandler that wraps an existing Handler.
|
||||
|
||||
The wrapped handler will meet all the execution guarantees of
|
||||
the original Handler object.
|
||||
*/
|
||||
|
||||
205
modules/beast_asio/async/WrapHandler.h
Normal file
205
modules/beast_asio/async/WrapHandler.h
Normal file
@@ -0,0 +1,205 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef BEAST_ASIO_WRAPHANDLER_H_INCLUDED
|
||||
#define BEAST_ASIO_WRAPHANDLER_H_INCLUDED
|
||||
|
||||
namespace beast {
|
||||
namespace detail {
|
||||
|
||||
// Wrapper returned by wrapHandler, calls the Handler in the given Context
|
||||
//
|
||||
template <typename Handler, typename Context>
|
||||
class WrappedHandler
|
||||
{
|
||||
public:
|
||||
typedef void result_type; // for result_of
|
||||
|
||||
WrappedHandler (Handler& handler, Context const& context)
|
||||
: m_handler (handler)
|
||||
, m_context (context)
|
||||
{
|
||||
}
|
||||
|
||||
WrappedHandler (Handler const& handler, Context const& context)
|
||||
: m_handler (handler)
|
||||
, m_context (context)
|
||||
{
|
||||
}
|
||||
|
||||
#if BEAST_COMPILER_SUPPORTS_MOVE_SEMANTICS
|
||||
WrappedHandler (WrappedHandler const& other)
|
||||
: m_handler (other.m_handler)
|
||||
, m_context (other.m_context)
|
||||
{
|
||||
}
|
||||
|
||||
WrappedHandler (BEAST_MOVE_ARG(WrappedHandler) other)
|
||||
: m_handler (BEAST_MOVE_CAST(Handler)(other.m_handler))
|
||||
, m_context (BEAST_MOVE_CAST(Context)(other.m_context))
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
Handler& handler()
|
||||
{ return m_handler; }
|
||||
|
||||
Handler const& handler() const
|
||||
{ return m_handler; }
|
||||
|
||||
Context& context()
|
||||
{ return m_context; }
|
||||
|
||||
Context const& context() const
|
||||
{ return m_context; }
|
||||
|
||||
void operator() ()
|
||||
{ m_handler(); }
|
||||
|
||||
void operator() () const
|
||||
{ m_handler(); }
|
||||
|
||||
template <class P1>
|
||||
void operator() (P1 const& p1)
|
||||
{ m_handler(p1); }
|
||||
|
||||
template <class P1>
|
||||
void operator() (P1 const& p1) const
|
||||
{ m_handler(p1); }
|
||||
|
||||
template <class P1, class P2>
|
||||
void operator() (P1 const& p1, P2 const& p2)
|
||||
{ m_handler(p1, p2); }
|
||||
|
||||
template <class P1, class P2>
|
||||
void operator() (P1 const& p1, P2 const& p2) const
|
||||
{ m_handler(p1, p2); }
|
||||
|
||||
template <class P1, class P2, class P3>
|
||||
void operator() (P1 const& p1, P2 const& p2, P3 const& p3)
|
||||
{ m_handler(p1, p2, p3); }
|
||||
|
||||
template <class P1, class P2, class P3>
|
||||
void operator() (P1 const& p1, P2 const& p2, P3 const& p3) const
|
||||
{ m_handler(p1, p2, p3); }
|
||||
|
||||
template <class P1, class P2, class P3, class P4>
|
||||
void operator()
|
||||
(P1 const& p1, P2 const& p2, P3 const& p3, P4 const& p4)
|
||||
{ m_handler(p1, p2, p3, p4); }
|
||||
|
||||
template <class P1, class P2, class P3, class P4>
|
||||
void operator()
|
||||
(P1 const& p1, P2 const& p2, P3 const& p3, P4 const& p4) const
|
||||
{ m_handler(p1, p2, p3, p4); }
|
||||
|
||||
template <class P1, class P2, class P3,
|
||||
class P4, class P5>
|
||||
void operator() (P1 const& p1, P2 const& p2, P3 const& p3,
|
||||
P4 const& p4, P5 const& p5)
|
||||
{ m_handler(p1, p2, p3, p4, p5); }
|
||||
|
||||
template <class P1, class P2, class P3,
|
||||
class P4, class P5>
|
||||
void operator() (P1 const& p1, P2 const& p2, P3 const& p3,
|
||||
P4 const& p4, P5 const& p5) const
|
||||
{ m_handler(p1, p2, p3, p4, p5); }
|
||||
|
||||
template <class P1, class P2, class P3,
|
||||
class P4, class P5, class P6>
|
||||
void operator() (P1 const& p1, P2 const& p2, P3 const& p3,
|
||||
P4 const& p4, P5 const& p5, P6 const& p6)
|
||||
{ m_handler(p1, p2, p3, p4, p5, p6); }
|
||||
|
||||
template <class P1, class P2, class P3,
|
||||
class P4, class P5, class P6>
|
||||
void operator() (P1 const& p1, P2 const& p2, P3 const& p3,
|
||||
P4 const& p4, P5 const& p5, P6 const& p6) const
|
||||
{ m_handler(p1, p2, p3, p4, p5, p6); }
|
||||
|
||||
private:
|
||||
Handler m_handler;
|
||||
Context m_context;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
template <typename Handler, typename Context>
|
||||
void* asio_handler_allocate (std::size_t size,
|
||||
WrappedHandler <Handler, Context>* this_handler)
|
||||
{
|
||||
return boost_asio_handler_alloc_helpers::allocate(
|
||||
size, this_handler->context());
|
||||
}
|
||||
|
||||
template <typename Handler, typename Context>
|
||||
void asio_handler_deallocate (void* pointer, std::size_t size,
|
||||
WrappedHandler <Handler, Context>* this_handler)
|
||||
{
|
||||
boost_asio_handler_alloc_helpers::deallocate(
|
||||
pointer, size, this_handler->context());
|
||||
}
|
||||
|
||||
template <typename Handler, typename Context>
|
||||
bool asio_handler_is_continuation(
|
||||
WrappedHandler <Handler, Context>* this_handler)
|
||||
{
|
||||
return boost_asio_handler_cont_helpers::is_continuation(
|
||||
this_handler->handler());
|
||||
}
|
||||
|
||||
template <typename Function, typename Handler, typename Context>
|
||||
void asio_handler_invoke (Function& function,
|
||||
WrappedHandler <Handler, Context>* handler)
|
||||
{
|
||||
boost_asio_handler_invoke_helpers::invoke(
|
||||
function, handler->context());
|
||||
}
|
||||
|
||||
template <typename Function, typename Handler, typename Context>
|
||||
void asio_handler_invoke (Function const& function,
|
||||
WrappedHandler <Handler, Context>* handler)
|
||||
{
|
||||
boost_asio_handler_invoke_helpers::invoke(
|
||||
function, handler->context());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** Returns a handler that calls Handler using Context hooks.
|
||||
This is useful when implementing composed asynchronous operations that
|
||||
need to call their own intermediate handlers before issuing the final
|
||||
completion to the original handler.
|
||||
*/
|
||||
template <typename Handler, typename Context>
|
||||
detail::WrappedHandler <Handler, Context>
|
||||
wrapHandler (
|
||||
BEAST_MOVE_ARG(Handler) handler,
|
||||
BEAST_MOVE_ARG(Context) context)
|
||||
{
|
||||
return detail::WrappedHandler <Handler, Context> (
|
||||
BEAST_MOVE_CAST(Handler)(handler),
|
||||
BEAST_MOVE_CAST(Context)(context));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -57,8 +57,10 @@
|
||||
#include "../../beast/Utility.h"
|
||||
#include "../../beast/HTTP.h"
|
||||
|
||||
namespace beast
|
||||
{
|
||||
#include "async/AbstractHandler.h"
|
||||
#include "async/WrapHandler.h"
|
||||
|
||||
namespace beast {
|
||||
|
||||
// Order matters
|
||||
# include "async/SharedHandler.h"
|
||||
@@ -88,8 +90,13 @@ namespace beast
|
||||
# include "http/HTTPRequest.h"
|
||||
# include "http/HTTPResponse.h"
|
||||
# include "http/HTTPParser.h"
|
||||
|
||||
}
|
||||
|
||||
#include "http/HTTPClientType.h"
|
||||
|
||||
namespace beast {
|
||||
|
||||
# include "protocol/InputParser.h"
|
||||
# include "protocol/HandshakeDetectLogic.h"
|
||||
#include "protocol/HandshakeDetectLogicPROXY.h"
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -20,46 +20,49 @@
|
||||
#ifndef BEAST_ASIO_HTTPCLIENTTYPE_H_INCLUDED
|
||||
#define BEAST_ASIO_HTTPCLIENTTYPE_H_INCLUDED
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace beast {
|
||||
|
||||
class HTTPClientBase
|
||||
{
|
||||
public:
|
||||
struct Result
|
||||
{
|
||||
boost::system::error_code error;
|
||||
SharedPtr <HTTPResponse> response;
|
||||
};
|
||||
|
||||
class Listener
|
||||
{
|
||||
public:
|
||||
virtual void onHTTPRequestComplete (
|
||||
HTTPClientBase const& client,
|
||||
Result const& result) = 0;
|
||||
};
|
||||
typedef boost::system::error_code error_type;
|
||||
typedef SharedPtr <HTTPResponse> value_type;
|
||||
typedef std::pair <error_type, value_type> result_type;
|
||||
|
||||
static HTTPClientBase* New (
|
||||
Journal journal = Journal(),
|
||||
double timeoutSeconds = 30,
|
||||
std::size_t messageLimitBytes = 256 * 1024,
|
||||
std::size_t bufferSize = 16 * 1024);
|
||||
|
||||
/** Destroy the client.
|
||||
This will cancel any pending i/o and block until all completion
|
||||
handlers have been called.
|
||||
*/
|
||||
virtual ~HTTPClientBase () { }
|
||||
|
||||
virtual Result const& result () const = 0;
|
||||
virtual result_type get (URL const& url) = 0;
|
||||
|
||||
virtual Result const& get (
|
||||
URL const& url) = 0;
|
||||
template <typename GetHandler>
|
||||
void async_get (boost::asio::io_service& io_service,
|
||||
URL const& url, GetHandler handler)
|
||||
{
|
||||
abstract_async_get (io_service, url,
|
||||
AbstractHandler <void (result_type)> (handler));
|
||||
}
|
||||
|
||||
virtual void async_get (boost::asio::io_service& io_service,
|
||||
Listener* listener,
|
||||
URL const& url) = 0;
|
||||
virtual void abstract_async_get (boost::asio::io_service& io_service,
|
||||
URL const& url, AbstractHandler <void (result_type)> handler) = 0;
|
||||
|
||||
/** Cancel any pending asynchronous operations.
|
||||
This must be called before destroying the container if there are
|
||||
any pending asynchronous operations. This routine does nothing if
|
||||
there are no pending operations. The call will block until all
|
||||
pending i/o is canceled.
|
||||
*/
|
||||
virtual void cancel () = 0;
|
||||
/** Cancel any pending asynchronous operations. */
|
||||
virtual void cancel() = 0;
|
||||
|
||||
/** Block until all asynchronous i/o completes. */
|
||||
virtual void wait() = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user