Krzysztof Grobelny | e6d4887 | 2022-02-08 13:41:30 +0100 | [diff] [blame] | 1 | #include "messanger_service.hpp" |
| 2 | |
| 3 | namespace utils |
| 4 | { |
| 5 | |
| 6 | MessangerService::MessangerService( |
| 7 | boost::asio::execution_context& execution_context) : |
| 8 | boost::asio::execution_context::service(execution_context) |
| 9 | {} |
| 10 | |
| 11 | MessangerService::Context& MessangerService::create() |
| 12 | { |
| 13 | contexts_.emplace_back(std::make_unique<Context>()); |
| 14 | return *contexts_.back(); |
| 15 | } |
| 16 | |
| 17 | void MessangerService::destroy(MessangerService::Context& context) |
| 18 | { |
Patrick Williams | 3a1c297 | 2023-05-10 07:51:04 -0500 | [diff] [blame] | 19 | contexts_.erase( |
| 20 | std::remove_if( |
| 21 | contexts_.begin(), contexts_.end(), |
| 22 | [&context](const auto& item) { return item.get() == &context; }), |
| 23 | contexts_.end()); |
Krzysztof Grobelny | e6d4887 | 2022-02-08 13:41:30 +0100 | [diff] [blame] | 24 | } |
| 25 | |
| 26 | boost::asio::execution_context::id MessangerService::id = {}; |
| 27 | |
| 28 | } // namespace utils |