| 55 | } |
| 56 | |
| 57 | void config_from_concurrency_hint_test() |
| 58 | { |
| 59 | boost::asio::io_context ctx0; |
| 60 | |
| 61 | boost::asio::config cfg0(ctx0); |
| 62 | BOOST_ASIO_CHECK(cfg0.get("scheduler", "concurrency_hint", 0) == -1); |
| 63 | BOOST_ASIO_CHECK(cfg0.get("scheduler", "locking", false) == true); |
| 64 | BOOST_ASIO_CHECK(cfg0.get("reactor", "registration_locking", true) == true); |
| 65 | BOOST_ASIO_CHECK(cfg0.get("reactor", "io_locking", false) == true); |
| 66 | |
| 67 | boost::asio::io_context ctx1(0); |
| 68 | |
| 69 | boost::asio::config cfg1(ctx1); |
| 70 | BOOST_ASIO_CHECK(cfg1.get("scheduler", "concurrency_hint", 0) == 0); |
| 71 | BOOST_ASIO_CHECK(cfg1.get("scheduler", "locking", false) == true); |
| 72 | BOOST_ASIO_CHECK(cfg1.get("reactor", "registration_locking", true) == true); |
| 73 | BOOST_ASIO_CHECK(cfg1.get("reactor", "io_locking", false) == true); |
| 74 | |
| 75 | boost::asio::io_context ctx2(1); |
| 76 | |
| 77 | boost::asio::config cfg2(ctx2); |
| 78 | BOOST_ASIO_CHECK(cfg2.get("scheduler", "concurrency_hint", 0) == 1); |
| 79 | BOOST_ASIO_CHECK(cfg2.get("scheduler", "locking", false) == true); |
| 80 | BOOST_ASIO_CHECK(cfg2.get("reactor", "registration_locking", true) == true); |
| 81 | BOOST_ASIO_CHECK(cfg2.get("reactor", "io_locking", false) == true); |
| 82 | |
| 83 | boost::asio::io_context ctx3(42); |
| 84 | |
| 85 | boost::asio::config cfg3(ctx3); |
| 86 | BOOST_ASIO_CHECK(cfg3.get("scheduler", "concurrency_hint", 0) == 42); |
| 87 | BOOST_ASIO_CHECK(cfg3.get("scheduler", "locking", false) == true); |
| 88 | BOOST_ASIO_CHECK(cfg3.get("reactor", "registration_locking", true) == true); |
| 89 | BOOST_ASIO_CHECK(cfg3.get("reactor", "io_locking", false) == true); |
| 90 | |
| 91 | boost::asio::io_context ctx4(BOOST_ASIO_CONCURRENCY_HINT_UNSAFE); |
| 92 | |
| 93 | boost::asio::config cfg4(ctx4); |
| 94 | BOOST_ASIO_CHECK(cfg4.get("scheduler", "concurrency_hint", 0) == 1); |
| 95 | BOOST_ASIO_CHECK(cfg4.get("scheduler", "locking", false) == false); |
| 96 | BOOST_ASIO_CHECK(cfg4.get("reactor", "registration_locking", true) == false); |
| 97 | BOOST_ASIO_CHECK(cfg4.get("reactor", "io_locking", false) == false); |
| 98 | |
| 99 | boost::asio::io_context ctx5(BOOST_ASIO_CONCURRENCY_HINT_UNSAFE_IO); |
| 100 | |
| 101 | boost::asio::config cfg5(ctx5); |
| 102 | BOOST_ASIO_CHECK(cfg5.get("scheduler", "concurrency_hint", 0) == 1); |
| 103 | BOOST_ASIO_CHECK(cfg5.get("scheduler", "locking", false) == true); |
| 104 | BOOST_ASIO_CHECK(cfg5.get("reactor", "registration_locking", true) == true); |
| 105 | BOOST_ASIO_CHECK(cfg5.get("reactor", "io_locking", false) == false); |
| 106 | |
| 107 | boost::asio::io_context ctx6(BOOST_ASIO_CONCURRENCY_HINT_SAFE); |
| 108 | |
| 109 | boost::asio::config cfg6(ctx6); |
| 110 | BOOST_ASIO_CHECK(cfg6.get("scheduler", "concurrency_hint", 0) == -1); |
| 111 | BOOST_ASIO_CHECK(cfg6.get("scheduler", "locking", false) == true); |
| 112 | BOOST_ASIO_CHECK(cfg6.get("reactor", "registration_locking", true) == true); |
| 113 | BOOST_ASIO_CHECK(cfg6.get("reactor", "io_locking", false) == true); |
| 114 | } |