Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix compilation with tracing and new network_element_t
[simgrid.git] / examples / lua / state_cloner / duplicated_globals.lua
1 -- This code creates 3 simgrid processes and verifies that the global values
2 -- in each Lua world are correctly cloned from maestro and become different
3
4 require("simgrid")
5
6 global_string = "A global string set by maestro"
7
8 -- Assigns to the global string the first argument and prints it
9 function set_global_string(...)
10   
11   global_string = arg[1]
12   simgrid.info("Changing the global string")
13   print_global()
14 end
15
16 -- Replaces the function please_dont_change_me() by set_global_string()
17 -- and calls it
18 function replace(...)
19
20   simgrid.info("Overwriting function please_dont_replace_me()")
21   please_dont_replace_me = set_global_string
22   please_dont_replace_me(...)
23 end
24
25 -- Shows a hello message and prints the global string
26 function please_dont_replace_me(...)
27
28   simgrid.info("Hello from please_dont_replace_me(). I'm lucky, I still exist in this state.")
29   print_global()
30 end
31
32 -- Prints the value of global_string
33 function print_global()
34
35   simgrid.info("Global string is '" .. global_string .. "'")
36 end
37
38 print_global()
39
40 simgrid.platform("../../msg/small_platform.xml")
41 simgrid.application("deployment_duplicated_globals.xml")
42 simgrid.run()
43