Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/xcomm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
}

Expand Down Expand Up @@ -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();
}
};
}
Expand All @@ -152,11 +152,10 @@ namespace xpyt
// deletion by the garbage collector
pycomm.inc_ref();
xcomm& comm = pycomm.cast<xcomm&>();
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;
}

/***************
Expand Down
10 changes: 2 additions & 8 deletions src/xcomm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace xpyt
{
public:

using close_callback_type = std::function<void(std::string)>;
using close_callback_type = std::function<void()>;
using python_callback_type = std::function<void(py::object)>;
using cpp_callback_type = std::function<void(const xeus::xmessage&)>;
using buffers_sequence = xeus::buffer_sequence;
Expand Down Expand Up @@ -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<std::string, py::object> m_comms;
};

py::module get_comm_module();
Expand Down
Loading