-
-static void smx_ctx_lua_suspend(smx_context_t context)
-{
- INFO1("Suspending %s",context->argv[0]);
- lua_yield(((smx_ctx_lua_t)context)->state,0); // Should be the last line of the function
-// INFO1("Suspended %s",context->argv[0]);
+static void smx_ctx_lua_suspend(smx_context_t pcontext) {
+ smx_ctx_lua_t context = (smx_ctx_lua_t)pcontext;
+ DEBUG1("Suspending '%s' (calling lua_yield)",context->argv[0]);
+ //lua_yield(context->state,0);
+
+ lua_getglobal(context->state,"doyield");
+ xbt_assert0(lua_isfunction(context->state,-1),
+ "Cannot find the coroutine.yield function...");
+ INFO0("Call coroutine.yield");
+ lua_call(context->state,0,0);
+ INFO0("Back from call to coroutine.yield");