How to use the simgrid.Mailbox.by_name function in simgrid

To help you get started, we’ve selected a few simgrid examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github simgrid / simgrid / examples / python / async-waitany / async-waitany.py View on Github external
def __call__(self):
        # List in which we store all ongoing communications
        pending_comms = []

        # Vector of the used mailboxes
        mboxes = [Mailbox.by_name("receiver-{:d}".format(i))
                  for i in range(0, self.receivers_count)]

        # Start dispatching all messages to receivers, in a round robin fashion
        for i in range(0, self.messages_count):
            content = "Message {:d}".format(i)
            mbox = mboxes[i % self.receivers_count]

            this_actor.info("Send '{:s}' to '{:s}'".format(content, str(mbox)))

            # Create a communication representing the ongoing communication, and store it in pending_comms
            comm = mbox.put_async(content, self.msg_size)
            pending_comms.append(comm)

        # Start sending messages to let the workers know that they should stop
        for i in range(0, self.receivers_count):
            mbox = mboxes[i]
github simgrid / simgrid / examples / python / actor-create / actor-create.py View on Github external
def forwarder(*args):
    """Our second class of actors is also a function"""
    if len(args) < 2:
        raise AssertionError(
            "Actor forwarder requires 2 parameters, but got only {:d}".format(len(args)))
    mb_in = Mailbox.by_name(args[0])
    mb_out = Mailbox.by_name(args[1])

    msg = mb_in.get()
    this_actor.info("Forward '{:s}'.".format(msg))
    mb_out.put(msg, len(msg))
github simgrid / simgrid / examples / python / async-wait / async-wait.py View on Github external
def __call__(self):
        # List in which we store all ongoing communications
        pending_comms = []

        # Vector of the used mailboxes
        mboxes = [Mailbox.by_name("receiver-{:d}".format(i)) for i in range(0, self.receivers_count)]

        # Start dispatching all messages to receivers, in a round robin fashion
        for i in range(0, self.messages_count):
            content = "Message {:d}".format(i)
            mbox = mboxes[i % self.receivers_count]

            this_actor.info("Send '{:s}' to '{:s}'".format(content, str(mbox)))

            # Create a communication representing the ongoing communication, and store it in pending_comms
            comm = mbox.put_async(content, self.msg_size)
            pending_comms.append(comm)

        # Start sending messages to let the workers know that they should stop
        for i in range(0, self.receivers_count):
            mbox = mboxes[i]
            this_actor.info("Send 'finalize' to '{:s}'".format(str(mbox)))
github simgrid / simgrid / examples / python / actor-create / actor-create.py View on Github external
def __call__(self):
        this_actor.info("Hello s4u, I have something to send")
        mailbox = Mailbox.by_name(self.mbox)

        mailbox.put(self.msg, len(self.msg))
        this_actor.info("I'm done. See you.")
github simgrid / simgrid / examples / python / async-waitall / async-waitall.py View on Github external
def __call__(self):
        # List in which we store all ongoing communications
        pending_comms = []

        # Vector of the used mailboxes
        mboxes = [Mailbox.by_name("receiver-{:d}".format(i))
                  for i in range(0, self.receivers_count)]

        # Start dispatching all messages to receivers, in a round robin fashion
        for i in range(0, self.messages_count):
            content = "Message {:d}".format(i)
            mbox = mboxes[i % self.receivers_count]

            this_actor.info("Send '{:s}' to '{:s}'".format(content, str(mbox)))

            # Create a communication representing the ongoing communication, and store it in pending_comms
            comm = mbox.put_async(content, self.msg_size)
            pending_comms.append(comm)

        # Start sending messages to let the workers know that they should stop
        for i in range(0, self.receivers_count):
            mbox = mboxes[i]