示例#1
0
def victim_a_fun():
    this_actor.on_exit(lambda: this_actor.info("I have been killed!"))
    this_actor.info("Hello!")
    this_actor.info("Suspending myself")
    this_actor.suspend()                        # - Start by suspending itself
    # - Then is resumed and start to execute a task
    this_actor.info("OK, OK. Let's work")
    this_actor.execute(1e9)
    # - But will never reach the end of it
    this_actor.info("Bye!")
示例#2
0
def worker(first_host, second_host):
    flop_amount = first_host.speed * 5 + second_host.speed * 5

    this_actor.info("Let's move to {:s} to execute {:.2f} Mflops (5sec on {:s} and 5sec on {:s})".format(
        first_host.name, flop_amount / 1e6, first_host.name, second_host.name))

    this_actor.set_host(first_host)
    this_actor.execute(flop_amount)

    this_actor.info("I wake up on {:s}. Let's suspend a bit".format(
        this_actor.get_host().name))

    this_actor.suspend()

    this_actor.info("I wake up on {:s}".format(this_actor.get_host().name))
    this_actor.info("Done")
示例#3
0
def lazy_guy():
    """The Lazy guy only wants to sleep, but can be awaken by the dream_master process"""
    this_actor.info("Nobody's watching me ? Let's go to sleep.")
    this_actor.suspend()  # - Start by suspending itself
    this_actor.info("Uuuh ? Did somebody call me ?")

    # - Then repetitively go to sleep, but get awaken
    this_actor.info("Going to sleep...")
    this_actor.sleep_for(10)
    this_actor.info("Mmm... waking up.")

    this_actor.info("Going to sleep one more time (for 10 sec)...")
    this_actor.sleep_for(10)
    this_actor.info("Waking up once for all!")

    this_actor.info("Ok, let's do some work, then (for 10 sec on Boivin).")
    this_actor.execute(980.95e6)

    this_actor.info("Mmmh, I'm done now. Goodbye.")