Example #1
0
static void *aura_eventsys_get_autocreate(struct aura_node *node)
{
    struct aura_eventloop *loop = aura_eventloop_get_data(node);
    if (loop == NULL) {
        slog(3, SLOG_DEBUG, "aura: Auto-creating eventsystem for node");
        loop = aura_eventloop_create(node);
        if (!loop) {
            slog(0, SLOG_ERROR, "aura: eventloop auto-creation failed");
            aura_panic(node);
        }
        loop->autocreated = 1;
        aura_eventloop_set_data(node, loop);
    }
    return loop;
}
Example #2
0
static int l_eventloop_create(lua_State *L)
{
	struct laura_node *lnode;
	struct laura_eventloop *lloop;

	TRACE();

	lnode = lua_fetch_node(L, 1);
	if (!lnode)
		return luaL_error(L, "Failed to fetch node");

	lloop = lua_newuserdata(L, sizeof(*lloop));
	if (!lloop)
		return luaL_error(L, "Userdata allocation failed");
	luaL_setmetatable(L, laura_eventloop_type);

	lloop->loop = aura_eventloop_create(lnode->node);
	if (!lloop->loop)
		lua_pushnil(L);

	return 1;
}