Commit 449daaceadc6bb9915381920ecd05d81e82fb88f
1 parent
7472b5a4
C++ std cleanup
Showing
2 changed files
with
6 additions
and
7 deletions
02-timer3.cpp
| @@ -10,7 +10,6 @@ | @@ -10,7 +10,6 @@ | ||
| 10 | 10 | ||
| 11 | #include <iostream> | 11 | #include <iostream> |
| 12 | #include <asio.hpp> | 12 | #include <asio.hpp> |
| 13 | -#include <boost/bind/bind.hpp> | ||
| 14 | 13 | ||
| 15 | void print(const asio::error_code& /*e*/, | 14 | void print(const asio::error_code& /*e*/, |
| 16 | asio::steady_timer* t, int* count) | 15 | asio::steady_timer* t, int* count) |
04-timer5.cpp
| @@ -10,7 +10,6 @@ | @@ -10,7 +10,6 @@ | ||
| 10 | 10 | ||
| 11 | #include <iostream> | 11 | #include <iostream> |
| 12 | #include <asio.hpp> | 12 | #include <asio.hpp> |
| 13 | -#include <boost/bind/bind.hpp> | ||
| 14 | 13 | ||
| 15 | class printer | 14 | class printer |
| 16 | { | 15 | { |
| @@ -22,10 +21,10 @@ public: | @@ -22,10 +21,10 @@ public: | ||
| 22 | count_(0) | 21 | count_(0) |
| 23 | { | 22 | { |
| 24 | timer1_.async_wait(asio::bind_executor(strand_, | 23 | timer1_.async_wait(asio::bind_executor(strand_, |
| 25 | - boost::bind(&printer::print1, this))); | 24 | + std::bind(&printer::print1, this))); |
| 26 | 25 | ||
| 27 | timer2_.async_wait(asio::bind_executor(strand_, | 26 | timer2_.async_wait(asio::bind_executor(strand_, |
| 28 | - boost::bind(&printer::print2, this))); | 27 | + std::bind(&printer::print2, this))); |
| 29 | } | 28 | } |
| 30 | 29 | ||
| 31 | ~printer() | 30 | ~printer() |
| @@ -43,7 +42,7 @@ public: | @@ -43,7 +42,7 @@ public: | ||
| 43 | timer1_.expires_at(timer1_.expiry() + asio::chrono::seconds(1)); | 42 | timer1_.expires_at(timer1_.expiry() + asio::chrono::seconds(1)); |
| 44 | 43 | ||
| 45 | timer1_.async_wait(asio::bind_executor(strand_, | 44 | timer1_.async_wait(asio::bind_executor(strand_, |
| 46 | - boost::bind(&printer::print1, this))); | 45 | + std::bind(&printer::print1, this))); |
| 47 | } | 46 | } |
| 48 | } | 47 | } |
| 49 | 48 | ||
| @@ -57,7 +56,7 @@ public: | @@ -57,7 +56,7 @@ public: | ||
| 57 | timer2_.expires_at(timer2_.expiry() + asio::chrono::seconds(1)); | 56 | timer2_.expires_at(timer2_.expiry() + asio::chrono::seconds(1)); |
| 58 | 57 | ||
| 59 | timer2_.async_wait(asio::bind_executor(strand_, | 58 | timer2_.async_wait(asio::bind_executor(strand_, |
| 60 | - boost::bind(&printer::print2, this))); | 59 | + std::bind(&printer::print2, this))); |
| 61 | } | 60 | } |
| 62 | } | 61 | } |
| 63 | 62 | ||
| @@ -72,7 +71,8 @@ int main() | @@ -72,7 +71,8 @@ int main() | ||
| 72 | { | 71 | { |
| 73 | asio::io_context io; | 72 | asio::io_context io; |
| 74 | printer p(io); | 73 | printer p(io); |
| 75 | - asio::thread t(boost::bind(&asio::io_context::run, &io)); | 74 | +// std::thread t(std::bind(&asio::io_context::run, &io)); |
| 75 | + std::thread t([&io]{io.run();}); | ||
| 76 | io.run(); | 76 | io.run(); |
| 77 | t.join(); | 77 | t.join(); |
| 78 | 78 |