lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


 
Hi
	sorry . it is my fault after I read the 5.1 manal

	
lua_yield
          int lua_yield  (lua_State *L, int nresults);

Yields a coroutine. 

This function should only be called as the return expression of a C
function, as follows: 

       return lua_yield (L, nresults);

	so modify the code like 

//void MyYield(const char*szWait)
//{
//	cout << "thread is waiting for " << szWait << endl;
//	swait = szWait;
//	lua_yield(L2,0);
//}

//int luaMyYield(lua_State* LL)
//{
//	MyYield(lua_tostring(LL,1));
//	return 0;
//}

int MyYield(const char*szWait)
{
	cout << "thread is waiting for " << szWait << endl;
	swait = szWait;
	return lua_yield(L2,0);
}

int luaMyYield(lua_State* LL)
{
	return MyYield(lua_tostring(LL,1));
}

	but after do it , the lua works ok but luabind crashed ! 
	my God !