Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[Lua] Renamed host 'power' to 'speed' for hosts
[simgrid.git] / examples / lua / console / slave.lua
index 816fbda..89f5419 100644 (file)
@@ -1,13 +1,17 @@
+-- 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(...)
 
-  if #arg ~= 1 then
+  if select("#", ...) ~= 1 then
     error("Wrong number of arguments (got " .. #arg .. ", expected 1: slave_id)")
   end
 
-  local my_mailbox = "slave " .. arg[1]
+  local my_mailbox = "slave " .. select(1, ...)
   simgrid.info("Hello from lua, I'm a poor slave with mbox: " .. my_mailbox)
 
   while true do
@@ -19,7 +23,7 @@ function Slave(...)
       simgrid.info("Slave '" .. my_mailbox .. "' got finalize msg");
       break
     end
-    --local tk_name = simgrid.task.get_name(tk) 
+    --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")
@@ -27,5 +31,5 @@ function Slave(...)
 
   simgrid.info("Slave '" .. my_mailbox .. "': I'm Done . See You !!");
 
-end 
+end
 -- end_of_slave