Created
August 3, 2012 11:43
-
-
Save umegaya/3246882 to your computer and use it in GitHub Desktop.
yue emit sketch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int signal::operator () (int signo) { | |
event::signal ev = { signo }; | |
emit(ev); | |
} | |
struct emittable { | |
struct wait : public callable { | |
static int init(VM vm) { return callable::init<wait>(vm); } | |
static int call(VM vm); | |
}; | |
} | |
int lua::emittable::wait::call(VM vm) { | |
wait *w = reinterpret_cast<wait *>(lua_touserdata(vm, -1)); | |
U32 t_o = 0; future *ft = NULL; | |
if (w->timed()) { | |
t_o = lua_tointeger(vm, -2); | |
} | |
if (w->async()) { | |
ft = reinterpret_cast<future *>(lua_touserdata(vm, -3)); | |
} | |
coroutine *co = coroutine::to_co(vm); | |
lua_error_check(vm, co, "to_co"); | |
MSGID msgid = emittable::add_watcher(w->emitter(), *co); | |
lua_error_check(vm, msgid != serializer::INVALID_MSGID, "add_watcher"); | |
return ft ? 1 : co->yield(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment