X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/114b09ec24846920da14854ba06cf48d1d7d6dba..7ce752524bd815bb66b262e4288903c6a9ebfc93:/examples/lua/masterslave/slave.lua diff --git a/examples/lua/masterslave/slave.lua b/examples/lua/masterslave/slave.lua index 567db55037..e1ade873d4 100644 --- a/examples/lua/masterslave/slave.lua +++ b/examples/lua/masterslave/slave.lua @@ -1,21 +1,31 @@ +-- Copyright (c) 2011-2012, 2014. The SimGrid Team. +-- All rights reserved. + +-- This program is free software; you can redistribute it and/or modify it +-- under the terms of the license (GNU LGPL) which comes with this package. + function Slave(...) - local my_mailbox = "slave " .. arg[1] - simgrid.info("Hello from lua, I'm a poor slave with mbox: " .. my_mailbox) + if select("#", ...) ~= 1 then + error("Wrong number of arguments (got " .. #arg .. ", expected 1: slave_id)") + end + + local my_mailbox = "slave " .. select(1, ...) + simgrid.info("Hello from lua, I'm a poor slave with mailbox: " .. my_mailbox) while true do - local tk = simgrid.Task.recv(my_mailbox) - if (simgrid.Task.name(tk) == "finalize") then - simgrid.info("Slave '" .. my_mailbox .. "' got finalize msg") + local task = simgrid.task.recv(my_mailbox) + local task_name = task:get_name() + if (task_name == "finalize") then + simgrid.info("Got finalize message") break end - local task_name = simgrid.Task.name(tk) - simgrid.info("Slave '" .. my_mailbox.. "' processing " .. task_name) - simgrid.Task.execute(tk) - simgrid.info("Slave '" .. my_mailbox .. "': task " .. task_name .. " done") + simgrid.info("Received task '" .. task_name .. "' on mailbox '" .. my_mailbox .. "'") + task:execute() + simgrid.info("Task '" .. task_name .. "' is done") end - simgrid.info("Slave '" .. my_mailbox .. "': I'm Done . See You !!") -end -- Slave + simgrid.info("I'm done. See you!") +end -- end_of_slave