mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
6d5547a Set version to 1.0.0-b34 6fab138 Fix and tidy up CMake build scripts: ccefa54 Set version to 1.0.0-b33 32afe41 Set internal state correctly when writing frames: fe3e20b Add write_frames unit test 578dcd0 Add decorator unit test aaa3733 Use fwrite return value in file_body df66165 Require Visual Studio 2015 Update 3 or later b8e5a21 Set version to 1.0.0-b32 ffb1758 Update CMake scripts for finding packages: b893749 Remove http Writer suspend and resume feature (API Change): 27864fb Add io_service completion invariants tests eba05a7 Set version to 1.0.0-b31 484bcef Fix badge markdown in README.md 5663bea Add missing dynabuf_readstream member 0d7a551 Tidy up build settings 0fd4030 Move the handler, don't copy it git-subtree-dir: src/beast git-subtree-split: 6d5547a32c50ec95832c4779311502555ab0ee1f
115 lines
2.3 KiB
C++
115 lines
2.3 KiB
C++
//
|
|
// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
|
|
//
|
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
//
|
|
|
|
#ifndef BEAST_BIND_DETAIL_HANDLER_HPP
|
|
#define BEAST_BIND_DETAIL_HANDLER_HPP
|
|
|
|
#include <beast/core/handler_helpers.hpp>
|
|
#include <beast/core/detail/integer_sequence.hpp>
|
|
#include <utility>
|
|
|
|
namespace beast {
|
|
namespace detail {
|
|
|
|
/* Nullary handler that calls Handler with bound arguments.
|
|
|
|
The bound handler provides the same io_service execution
|
|
guarantees as the original handler.
|
|
*/
|
|
template<class Handler, class... Args>
|
|
class bound_handler
|
|
{
|
|
private:
|
|
using args_type = std::tuple<
|
|
typename std::decay<Args>::type...>;
|
|
|
|
Handler h_;
|
|
args_type args_;
|
|
|
|
template<class Tuple, std::size_t... S>
|
|
static void invoke(Handler& h, Tuple& args,
|
|
index_sequence<S...>)
|
|
{
|
|
h(std::get<S>(args)...);
|
|
}
|
|
|
|
public:
|
|
using result_type = void;
|
|
|
|
template<class DeducedHandler>
|
|
explicit
|
|
bound_handler(
|
|
DeducedHandler&& handler, Args&&... args)
|
|
: h_(std::forward<DeducedHandler>(handler))
|
|
, args_(std::forward<Args>(args)...)
|
|
{
|
|
}
|
|
|
|
void
|
|
operator()()
|
|
{
|
|
invoke(h_, args_,
|
|
index_sequence_for<Args...>());
|
|
}
|
|
|
|
void
|
|
operator()() const
|
|
{
|
|
invoke(h_, args_,
|
|
index_sequence_for<Args...>());
|
|
}
|
|
|
|
friend
|
|
void*
|
|
asio_handler_allocate(
|
|
std::size_t size, bound_handler* h)
|
|
{
|
|
return beast_asio_helpers::
|
|
allocate(size, h->h_);
|
|
}
|
|
|
|
friend
|
|
void
|
|
asio_handler_deallocate(
|
|
void* p, std::size_t size, bound_handler* h)
|
|
{
|
|
beast_asio_helpers::
|
|
deallocate(p, size, h->h_);
|
|
}
|
|
|
|
friend
|
|
bool
|
|
asio_handler_is_continuation(bound_handler* h)
|
|
{
|
|
return beast_asio_helpers::
|
|
is_continuation (h->h_);
|
|
}
|
|
|
|
template<class F>
|
|
friend
|
|
void
|
|
asio_handler_invoke(F&& f, bound_handler* h)
|
|
{
|
|
beast_asio_helpers::
|
|
invoke(f, h->h_);
|
|
}
|
|
};
|
|
|
|
} // detail
|
|
} // beast
|
|
|
|
#include <functional>
|
|
|
|
namespace std {
|
|
template<class Handler, class... Args>
|
|
void
|
|
bind(beast::detail::bound_handler<
|
|
Handler, Args...>, ...) = delete;
|
|
} // std
|
|
|
|
#endif
|