X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/201a288a0907c8c80037d719412fb139d67fe9c0..cfb3987654b857620ba388fab9883a095debeb72:/src/bindings/python/simgrid_python.cpp diff --git a/src/bindings/python/simgrid_python.cpp b/src/bindings/python/simgrid_python.cpp index a8e9ce79da..04f0a167a2 100644 --- a/src/bindings/python/simgrid_python.cpp +++ b/src/bindings/python/simgrid_python.cpp @@ -76,15 +76,6 @@ std::string get_simgrid_version() sg_version_get(&major, &minor, &patch); return simgrid::xbt::string_printf("%i.%i.%i", major, minor, patch); } - -/** @brief Wrap for mailbox::get_async */ -class PyGetAsync { - std::unique_ptr data = std::make_unique(); - -public: - PyObject** get() const { return data.get(); } -}; - } // namespace PYBIND11_DECLARE_HOLDER_TYPE(T, boost::intrusive_ptr) @@ -634,26 +625,14 @@ PYBIND11_MODULE(simgrid, m) "get", [](Mailbox* self) { return py::reinterpret_steal(self->get()); }, py::call_guard(), "Blocking data reception") .def( - "get_async", - [](Mailbox* self) -> std::tuple { - PyGetAsync wrap; - auto comm = self->get_async(wrap.get()); - return std::make_tuple(std::move(comm), std::move(wrap)); - }, + "get_async", [](Mailbox* self) -> CommPtr { return self->get_async(); }, py::call_guard(), "Non-blocking data reception. Use data.get() to get the python object after the communication has finished") .def("set_receiver", &Mailbox::set_receiver, py::call_guard(), "Sets the actor as permanent receiver"); - /* Class PyGetAsync */ - py::class_(m, "PyGetAsync", "Wrapper for async get communications") - .def(py::init<>()) - .def( - "get", [](const PyGetAsync* self) { return py::reinterpret_steal(*(self->get())); }, - "Get python object after async communication in receiver side"); - /* class Activity */ - py::class_(m, "Activityy", "Activity. See the C++ documentation for details."); + py::class_(m, "Activity", "Activity. See the C++ documentation for details."); /* Class Comm */ py::class_(m, "Comm", "Communication. See the C++ documentation for details.") @@ -693,6 +672,11 @@ PYBIND11_MODULE(simgrid, m) "Block until the completion of that communication, or raises TimeoutException after the specified timeout.") .def("wait_until", &Comm::wait_until, py::call_guard(), py::arg("time_limit"), "Block until the completion of that communication, or raises TimeoutException after the specified time.") + .def( + "get_payload", + [](const Comm* self) { return py::reinterpret_steal((PyObject*)self->get_payload()); }, + py::call_guard(), + "Retrieve the message's payload of a get_async. You cannot call this until after the comm termination.") .def("detach", py::overload_cast<>(&Comm::detach), py::return_value_policy::reference_internal, py::call_guard(), "Start the comm, and ignore its result. It can be completely forgotten after that.")