Event driven engine, further work.

This commit is contained in:
2021-10-05 12:54:37 -04:00
parent bc22dc89af
commit bce756d1fd
11 changed files with 61 additions and 115 deletions

View File

@@ -43,7 +43,7 @@ Channel *DrivenEngine::get_stdio_channel() {
return stdio_channel_.get();
}
std::unique_ptr<util::LuaSource> DrivenEngine::get_lua_source() {
util::LuaSourcePtr DrivenEngine::get_lua_source() {
return std::move(lua_source_);
}
@@ -68,14 +68,6 @@ void DrivenEngine::drv_logmode_none() {
// NOT IMPLEMENTED YET, but it's okay as a stub.
}
void DrivenEngine::drv_invoke_engine_init() {
init();
}
void DrivenEngine::drv_invoke_engine_update() {
update();
}
Channel *DrivenEngine::get_chid(int chid) {
// We cache the most recently used channel.
if (recent_channel_->chid_ != chid) {
@@ -110,7 +102,9 @@ void DrivenEngine::drv_sent_outgoing(int chid, int nbytes) {
}
void DrivenEngine::drv_recv_incoming(int chid, int nbytes, char *bytes) {
get_chid(chid)->sb_in_->write_bytes(bytes, nbytes);
if (nbytes > 0) {
get_chid(chid)->sb_in_->write_bytes(bytes, nbytes);
}
}
void DrivenEngine::drv_notify_close(int chid) {
@@ -127,11 +121,15 @@ void DrivenEngine::drv_set_clock(double t) {
clock_ = t;
}
void DrivenEngine::drv_set_lua_source(const util::LuaSource &source) {
lua_source_.reset(new util::LuaSource(source));
void DrivenEngine::drv_set_lua_source(util::LuaSourcePtr source) {
lua_source_ = std::move(source);
rescan_lua_source_ = false;
}
void DrivenEngine::drv_invoke_event_update() {
event_update();
}
bool DrivenEngine::drv_get_rescan_lua_source() {
return rescan_lua_source_;
}