]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/asio/test/experimental/prepend.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / asio / test / experimental / prepend.cpp
CommitLineData
1e59de90
TL
1//
2// experimental/prepend.cpp
3// ~~~~~~~~~~~~~~~~~~~~~~~~
4//
5// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6//
7// Distributed under the Boost Software License, Version 1.0. (See accompanying
8// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9//
10
11// Disable autolinking for unit tests.
12#if !defined(BOOST_ALL_NO_LIB)
13#define BOOST_ALL_NO_LIB 1
14#endif // !defined(BOOST_ALL_NO_LIB)
15
16// Test that header file is self-contained.
17#include <boost/asio/experimental/prepend.hpp>
18
19#include <boost/asio/bind_executor.hpp>
20#include <boost/asio/io_context.hpp>
21#include <boost/asio/post.hpp>
22#include <boost/asio/system_timer.hpp>
23#include "../unit_test.hpp"
24
25void prepend_test()
26{
27 boost::asio::io_context io1;
28 boost::asio::io_context io2;
29 boost::asio::system_timer timer1(io1);
30 int count = 0;
31
32 timer1.expires_after(boost::asio::chrono::seconds(0));
33 timer1.async_wait(
34 boost::asio::experimental::prepend(
35 boost::asio::bind_executor(io2.get_executor(),
36 [&count](int a, int b, boost::system::error_code)
37 {
38 ++count;
39 BOOST_ASIO_CHECK(a == 123);
40 BOOST_ASIO_CHECK(b == 321);
41 }), 123, 321));
42
43 BOOST_ASIO_CHECK(count == 0);
44
45 io1.run();
46
47 BOOST_ASIO_CHECK(count == 0);
48
49 io2.run();
50
51 BOOST_ASIO_CHECK(count == 1);
52}
53
54BOOST_ASIO_TEST_SUITE
55(
56 "experimental/basic_channel",
57 BOOST_ASIO_TEST_CASE(prepend_test)
58)