Ejemplo n.º 1
0
/*
 * Arguments: thread_udata
 */
static int
thread_resume_wrap (lua_State *L)
{
  struct sys_thread *td = checkudata(L, 1, THREAD_TYPENAME);

  sys_thread_resume(td);
  return 0;
}
Ejemplo n.º 2
0
static void
levq_sync_process (lua_State *L, struct event_queue *evq,
                   struct evq_sync_op *op)
{
    const int top = lua_gettop(L);

    do {
	lua_State *NL = op->L;

	if (op->is_sched_add) {
	    struct event *ev;

	    if (NL) {
		const int narg = lua_gettop(NL) - op->fn_idx;

		lua_xmove(NL, L, narg + 1);
		lua_call(L, narg, LUA_MULTRET);

		ev = lua_touserdata(L, top + 1);
		if (ev) {
		    ev->flags |= EVENT_ONESHOT | EVENT_CALLBACK_SCHED;
		    lua_pop(L, 1);  /* pop ev_ludata */
		} else {
		    /* error */
		    lua_xmove(L, NL, lua_gettop(L) - top);
		}
		sys_sched_event_added(NL, ev);
	    }
	    ev = (struct event *) op;
	    op = op->next;
	    levq_free_event(evq, ev);
	} else {
	    const int narg = lua_gettop(NL) - op->fn_idx;

	    op->status = lua_pcall(NL, narg, LUA_MULTRET, 0);
	    sys_thread_resume(op->td);
	    op = op->next;
	}
    } while (op);
}