aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/server/session_manager.cpp
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2019-12-07 03:36:21 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2019-12-07 03:36:21 +0300
commit00863566ec4601c65c435b74e575d49546a1c707 (patch)
tree479a0a6e96aba8191c7a65ea9bee2f4d5e3a4aba /server/session_manager.cpp
parentadd stress_test.py (diff)
downloadmath-server-00863566ec4601c65c435b74e575d49546a1c707.tar.gz
math-server-00863566ec4601c65c435b74e575d49546a1c707.zip
split server into multiple components
In a vague attempt to make header files more readable, split server/ into a number of components. Also, refactor the unit tests to use the "Data-driven test cases" of Boost.Test.
Diffstat (limited to 'server/session_manager.cpp')
-rw-r--r--server/session_manager.cpp37
1 files changed, 0 insertions, 37 deletions
diff --git a/server/session_manager.cpp b/server/session_manager.cpp
deleted file mode 100644
index a42fca4..0000000
--- a/server/session_manager.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-#include "log.hpp"
-#include "session.hpp"
-#include "session_manager.hpp"
-
-#include <memory>
-#include <mutex>
-
-namespace math::server {
-
-SessionPtr SessionManager::make_session(boost::asio::io_context& io_context) {
- return std::make_shared<Session>(*this, io_context);
-}
-
-void SessionManager::start(const SessionPtr& session) {
- std::lock_guard<std::mutex> lck{m_mtx};
- m_sessions.emplace(session);
- session->start();
-}
-
-void SessionManager::stop(const SessionPtr& session) {
- std::lock_guard<std::mutex> lck{m_mtx};
- const auto removed = m_sessions.erase(session) > 0;
- if (removed) {
- session->stop();
- }
-}
-
-void SessionManager::stop_all() {
- std::lock_guard<std::mutex> lck{m_mtx};
- log::log("Closing the remaining %1% session(s)...", m_sessions.size());
- for (const auto& session : m_sessions) {
- session->stop();
- }
- m_sessions.clear();
-}
-
-}