MCPcopy Create free account
hub / github.com/boostorg/asio / async_write_message

Function async_write_message

example/cpp11/operations/composed_2.cpp:89–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87
88template <typename CompletionToken>
89auto async_write_message(tcp::socket& socket,
90 const char* message, bool allow_partial_write,
91 CompletionToken&& token)
92 // The return type of the initiating function is deduced from the combination
93 // of:
94 //
95 // - the CompletionToken type,
96 // - the completion handler signature, and
97 // - the asynchronous operation's initiation function object.
98 //
99 // When the completion token is a simple callback, the return type is void.
100 // However, when the completion token is boost::asio::yield_context (used for
101 // stackful coroutines) the return type would be std::size_t, and when the
102 // completion token is boost::asio::use_future it would be std::future<std::size_t>.
103 // When the completion token is boost::asio::deferred, the return type differs for
104 // each asynchronous operation.
105 //
106 // In C++11 we deduce the type from the call to boost::asio::async_initiate.
107 -> decltype(
108 boost::asio::async_initiate<
109 CompletionToken, void(boost::system::error_code, std::size_t)>(
110 async_write_message_initiation(),
111 token, std::ref(socket), message, allow_partial_write))
112{
113 // The boost::asio::async_initiate function takes:
114 //
115 // - our initiation function object,
116 // - the completion token,
117 // - the completion handler signature, and
118 // - any additional arguments we need to initiate the operation.
119 //
120 // It then asks the completion token to create a completion handler (i.e. a
121 // callback) with the specified signature, and invoke the initiation function
122 // object with this completion handler as well as the additional arguments.
123 // The return value of async_initiate is the result of our operation's
124 // initiating function.
125 //
126 // Note that we wrap non-const reference arguments in std::reference_wrapper
127 // to prevent incorrect decay-copies of these objects.
128 return boost::asio::async_initiate<
129 CompletionToken, void(boost::system::error_code, std::size_t)>(
130 async_write_message_initiation(),
131 token, std::ref(socket), message, allow_partial_write);
132}
133
134//------------------------------------------------------------------------------
135

Callers 3

test_callbackFunction · 0.70
test_deferredFunction · 0.70
test_futureFunction · 0.70

Calls 2

refClass · 0.50

Tested by 3

test_callbackFunction · 0.56
test_deferredFunction · 0.56
test_futureFunction · 0.56