diff --git a/src/xcomm.cpp b/src/xcomm.cpp index 1ae915b1..ab9a06cc 100644 --- a/src/xcomm.cpp +++ b/src/xcomm.cpp @@ -83,7 +83,7 @@ namespace xpyt m_close_callback = std::move(callback); m_comm.on_close([this](const xeus::xmessage&) { - m_close_callback(comm_id()); + m_close_callback(); }); } @@ -128,7 +128,7 @@ namespace xpyt XPYT_HOLDING_GIL(py_callback(cppmessage_to_pymessage(msg))) if (m_close_callback) { - m_close_callback(comm_id()); + m_close_callback(); } }; } @@ -152,11 +152,10 @@ namespace xpyt // deletion by the garbage collector pycomm.inc_ref(); xcomm& comm = pycomm.cast(); - comm.on_close_cleanup([this](std::string id) + comm.on_close_cleanup([pycomm]() { - XPYT_HOLDING_GIL(m_comms.erase(id)) + XPYT_HOLDING_GIL(pycomm.dec_ref()) }); - m_comms[comm.comm_id()] = pycomm; } /*************** diff --git a/src/xcomm.hpp b/src/xcomm.hpp index de4af03f..5fface22 100644 --- a/src/xcomm.hpp +++ b/src/xcomm.hpp @@ -21,7 +21,7 @@ namespace xpyt { public: - using close_callback_type = std::function; + using close_callback_type = std::function; using python_callback_type = std::function; using cpp_callback_type = std::function; using buffers_sequence = xeus::buffer_sequence; @@ -58,18 +58,12 @@ namespace xpyt close_callback_type m_close_callback; }; - class xcomm_manager + struct xcomm_manager { - public: - xcomm_manager() = default; void register_target(const py::str& target_name, const py::object& callback); void register_comm(py::object comm); - - private: - - std::map m_comms; }; py::module get_comm_module();