Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:51:19

0001 /* Copyright (c) 2018-2023 Marcelo Zimbres Silva (mzimbres@gmail.com)
0002  *
0003  * Distributed under the Boost Software License, Version 1.0. (See
0004  * accompanying file LICENSE.txt)
0005  */
0006 
0007 #ifndef BOOST_REDIS_WRITE_HPP
0008 #define BOOST_REDIS_WRITE_HPP
0009 
0010 #include <boost/asio/write.hpp>
0011 #include <boost/redis/request.hpp>
0012 
0013 namespace boost::redis::detail {
0014 
0015 /** \brief Writes a request synchronously.
0016  *  \ingroup low-level-api
0017  *
0018  *  \param stream Stream to write the request to.
0019  *  \param req Request to write.
0020  */
0021 template<class SyncWriteStream>
0022 auto write(SyncWriteStream& stream, request const& req)
0023 {
0024    return asio::write(stream, asio::buffer(req.payload()));
0025 }
0026 
0027 template<class SyncWriteStream>
0028 auto write(SyncWriteStream& stream, request const& req, system::error_code& ec)
0029 {
0030    return asio::write(stream, asio::buffer(req.payload()), ec);
0031 }
0032 
0033 /** \brief Writes a request asynchronously.
0034  *  \ingroup low-level-api
0035  *
0036  *  \param stream Stream to write the request to.
0037  *  \param req Request to write.
0038  *  \param token Asio completion token.
0039  */
0040 template<
0041    class AsyncWriteStream,
0042    class CompletionToken = asio::default_completion_token_t<typename AsyncWriteStream::executor_type>
0043    >
0044 auto async_write(
0045    AsyncWriteStream& stream,
0046    request const& req,
0047    CompletionToken&& token =
0048       asio::default_completion_token_t<typename AsyncWriteStream::executor_type>{})
0049 {
0050    return asio::async_write(stream, asio::buffer(req.payload()), token);
0051 }
0052 
0053 } // boost::redis::detail
0054 
0055 #endif // BOOST_REDIS_WRITE_HPP