char *p=buff;
int i;
int top = lua_gettop(L);
-// void *ptr;
+
fflush(stdout);
p+=sprintf(p,"STACK(top=%d): ",top);
-/* lua_getglobal(L,"vardump");
- xbt_assert0(lua_isfunction(L,-1), "Vardump not found");
-*/
for (i = 1; i <= top; i++) { /* repeat for each level */
}
/** @brief leaves a new userdata on top of the stack, sets its metatable, and sets the Task pointer inside the userdata */
+// NOT USED
/*static m_task_t *pushTask (lua_State *L,m_task_t tk) {
-
m_task_t *pi = NULL;
pi = (m_task_t*)lua_newuserdata(L,sizeof(m_task_t));
*pi=tk;
-
DEBUG1("push lua task with Name : %s \n",MSG_task_get_name(*pi));
luaL_getmetatable(L,TASK_MODULE_NAME);
lua_setmetatable(L,-2);
return pi;
-
}*/
/* ********************************************************************************* */
return 1;
}
static int Task_send(lua_State *L) {
- stackDump("send ",L);
+ //stackDump("send ",L);
m_task_t tk = checkTask(L,-2);
const char *mailbox = luaL_checkstring(L,-1);
lua_pop(L,1); // remove the string so that the task is on top of it
MSG_task_set_data(tk,L); // Copy my stack into the task, so that the receiver can copy the lua task directly
MSG_error_t res = MSG_task_send(tk,mailbox);
- while (MSG_task_has_data(tk)) // Don't mess up with my stack: the receiver didn't copy the data yet
+ while (MSG_task_get_data(tk)!=NULL) // Don't mess up with my stack: the receiver didn't copy the data yet
MSG_process_sleep(0); // yield
if (res != MSG_OK) switch(res) {
}
return 0;
}
+
static int Task_recv(lua_State *L) {
m_task_t tk = NULL;
const char *mailbox = luaL_checkstring(L,-1);
m_host_t msg_host = MSG_get_host_by_name(name);
if (!msg_host)
{
- //ERROR1("MSG_get_host_by_name(%s) failled",name);
luaL_error(L,"null Host : MSG_get_host_by_name failled");
- //return -1;
}
lua_newtable (L); /* create a table, put the userdata on top of it */
m_host_t *lua_host = (m_host_t*)lua_newuserdata(L,sizeof(m_host_t));
static int run_lua_code(int argc,char **argv) {
DEBUG1("Run lua code %s",argv[0]);
-// fprintf(stderr,"Run lua code %s\n", (argv ? argv[0] : "(null)"));
lua_State *L = lua_newthread(simgrid_lua_state);
int ref = luaL_ref(simgrid_lua_state, LUA_REGISTRYINDEX); // protect the thread from being garbage collected
int res = 1;