X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/08e94eb0482589e4b287cbea301b84daf52635bd..3c4fb0b5a82e4449f6d6d8470714fcfb39c9db1b:/src/bindings/python/simgrid_python.cpp diff --git a/src/bindings/python/simgrid_python.cpp b/src/bindings/python/simgrid_python.cpp index ca675388b0..710f8f889e 100644 --- a/src/bindings/python/simgrid_python.cpp +++ b/src/bindings/python/simgrid_python.cpp @@ -15,6 +15,7 @@ #include "src/kernel/context/Context.hpp" #include #include +#include #include #include #include @@ -155,6 +156,9 @@ PYBIND11_MODULE(simgrid, m) /* Class Mailbox */ py::class_>(m, "Mailbox", "Mailbox, see :ref:`class s4u::Mailbox `") + .def("__str__", [](Mailbox self) -> const std::string { + return std::string("Mailbox(")+self.get_cname()+")"; + }, "Textual representation of the Mailbox`") .def("by_name", &Mailbox::by_name, "Retrieve a Mailbox from its name, see :cpp:func:`simgrid::s4u::Mailbox::by_name()`") .def_property_readonly("name", [](Mailbox* self) -> const std::string { return std::string(self->get_name().c_str()); // Convert from xbt::string because of MC @@ -163,12 +167,25 @@ PYBIND11_MODULE(simgrid, m) data.inc_ref(); self.put(data.ptr(), size); }, "Blocking data transmission, see :cpp:func:`void simgrid::s4u::Mailbox::put(void*, uint64_t)`") + .def("put_async", [](Mailbox self, py::object data, int size) -> simgrid::s4u::CommPtr { + data.inc_ref(); + return self.put_async(data.ptr(), size); + }, "Non-blocking data transmission, see :cpp:func:`void simgrid::s4u::Mailbox::put_async(void*, uint64_t)`") .def("get", [](Mailbox self) -> py::object { py::object data = pybind11::reinterpret_steal(pybind11::handle(static_cast(self.get()))); data.dec_ref(); return data; }, "Blocking data reception, see :cpp:func:`void* simgrid::s4u::Mailbox::get()`"); + /* Class Comm */ + py::class_(m, "Comm", "Communication, see :ref:`class s4u::Comm `") + .def("test", [](simgrid::s4u::CommPtr self) { + return self->test(); + }, "Test whether the communication is terminated, see :cpp:func:`simgrid::s4u::Comm::test()`") + .def("wait", [](simgrid::s4u::CommPtr self) { + self->wait(); + }, "Block until the completion of that communication, see :cpp:func:`simgrid::s4u::Comm::wait()`"); + /* Class Actor */ py::class_(m, "Actor", "An actor is an independent stream of execution in your distributed "