X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/edde8f7fbc1b74a81551bf9eb7bac1935b999296..5b3677b425b9cc6949c1573d59ac772540cbf4b2:/examples/lua/console/slave.lua diff --git a/examples/lua/console/slave.lua b/examples/lua/console/slave.lua index 1c77467105..b70a75a104 100644 --- a/examples/lua/console/slave.lua +++ b/examples/lua/console/slave.lua @@ -1,25 +1,35 @@ +-- Copyright (c) 2011, 2013-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. -- Slave Function --------------------------------------------------------- function Slave(...) -local my_mailbox="slave "..arg[1] -simgrid.info("Hello from lua, I'm a poor slave with mbox: "..my_mailbox) + if #arg ~= 1 then + error("Wrong number of arguments (got " .. #arg .. ", expected 1: slave_id)") + end -while true do + local my_mailbox = "slave " .. arg[1] + simgrid.info("Hello from lua, I'm a poor slave with mbox: " .. my_mailbox) - local tk = simgrid.task.recv(my_mailbox); - if (simgrid.task.get_name(tk) == "finalize") then - simgrid.info("Slave '" ..my_mailbox.."' got finalize msg"); - break - end - --local tk_name = simgrid.task.get_name(tk) - simgrid.info("Slave '" ..my_mailbox.."' processing "..simgrid.task.get_name(tk)) - simgrid.task.execute(tk) - simgrid.info("Slave '" ..my_mailbox.."': task "..simgrid.task.get_name(tk) .. " done") -end -- while + while true do + + local task = simgrid.task.recv(my_mailbox); + --print(task) + local task_name = task:get_name() + if (task:get_name() == "finalize") then + simgrid.info("Slave '" .. my_mailbox .. "' got finalize msg"); + break + end + --local tk_name = simgrid.task.get_name(tk) + simgrid.info("Slave '" .. my_mailbox .. "' processing " .. task:get_name()) + simgrid.task.execute(task) + simgrid.info("Slave '" .. my_mailbox .. "': task " .. task:get_name() .. " done") + end -- while -simgrid.info("Slave '" ..my_mailbox.."': I'm Done . See You !!"); + simgrid.info("Slave '" .. my_mailbox .. "': I'm Done . See You !!"); end -- end_of_slave