Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[Doc] Added description for the boost context factory
[simgrid.git] / examples / lua / masterslave / slave.lua
index a2b5439..e1ade87 100644 (file)
@@ -1,10 +1,16 @@
+-- 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(...)
 
-  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 mailbox: " .. my_mailbox)
 
   while true do
@@ -15,11 +21,11 @@ function Slave(...)
       simgrid.info("Got finalize message")
       break
     end
-    simgrid.info("Received task '" .. task_name .. "' on mailbox '" .. my_mailbox)
+    simgrid.info("Received task '" .. task_name .. "' on mailbox '" .. my_mailbox .. "'")
     task:execute()
     simgrid.info("Task '" .. task_name .. "' is done")
   end
 
   simgrid.info("I'm done. See you!")
-end -- Slave
+end -- end_of_slave