Finish implementing LUA_PROBE

This commit is contained in:
2024-09-05 01:33:14 -04:00
parent 2d8015c2ae
commit 2913f2bac2
6 changed files with 30 additions and 10 deletions

View File

@@ -31,11 +31,12 @@ eng::string Invocation::debug_string() const {
oss << "inv["; oss << "inv[";
switch (kind_) { switch (kind_) {
case InvocationKind::INVALID: oss << "invalid"; break; case InvocationKind::INVALID: oss << "invalid"; break;
case InvocationKind::LUA_CALL: oss << "lua_call"; break; case InvocationKind::LUA_INVOKE: oss << "lua_invoke"; break;
case InvocationKind::LUA_EXPR: oss << "lua"; break; case InvocationKind::LUA_PROBE: oss << "lua_probe"; break;
case InvocationKind::LUA_EXPR: oss << "lua_expr"; break;
case InvocationKind::LUA_SOURCE: oss << "lua_source"; break;
case InvocationKind::FLUSH_PRINTS: oss << "flush_prints"; break; case InvocationKind::FLUSH_PRINTS: oss << "flush_prints"; break;
case InvocationKind::TICK: oss << "tick"; break; case InvocationKind::TICK: oss << "tick"; break;
case InvocationKind::LUA_SOURCE: oss << "lua_source"; break;
default: oss << "UNKNOWN"; break; default: oss << "UNKNOWN"; break;
} }
oss << " a=" << actor_; oss << " a=" << actor_;

View File

@@ -247,8 +247,17 @@ public:
} }
virtual void event_call_function(InvocationKind kind, int64_t place_id, std::string_view datapk, StreamBuffer *retpk) override { virtual void event_call_function(InvocationKind kind, int64_t place_id, std::string_view datapk, StreamBuffer *retpk) override {
switch (kind) {
case InvocationKind::LUA_PROBE: {
world_to_asynchronous();
world_->probe_lua_call(actor_id_, place_id, datapk, retpk);
break;
}
default: {
delayed_invocations_.emplace_back(kind, actor_id_, place_id, datapk); delayed_invocations_.emplace_back(kind, actor_id_, place_id, datapk);
} }
}
}
virtual void event_update() override { virtual void event_update() override {
// Send invocations. We execute these using predictive execution. // Send invocations. We execute these using predictive execution.

View File

@@ -194,8 +194,18 @@ public:
} }
virtual void event_call_function(InvocationKind kind, int64_t place_id, std::string_view datapk, StreamBuffer *retpk) override { virtual void event_call_function(InvocationKind kind, int64_t place_id, std::string_view datapk, StreamBuffer *retpk) override {
switch (kind) {
case InvocationKind::LUA_PROBE: {
master_->snapshot();
master_->probe_lua_call(admin_id_, place_id, datapk, retpk);
master_->rollback();
break;
}
default: {
delayed_invocations_.emplace_back(kind, admin_id_, place_id, datapk); delayed_invocations_.emplace_back(kind, admin_id_, place_id, datapk);
} }
}
}
virtual void event_update() override { virtual void event_update() override {
// Get the clock. // Get the clock.

View File

@@ -700,7 +700,7 @@ void World::run_unittests() {
void World::invoke(const Invocation &inv) { void World::invoke(const Invocation &inv) {
switch (inv.kind()) { switch (inv.kind()) {
case InvocationKind::LUA_CALL: case InvocationKind::LUA_INVOKE:
invoke_lua_call(inv.actor(), inv.place(), inv.datapack()); invoke_lua_call(inv.actor(), inv.place(), inv.datapack());
break; break;
case InvocationKind::LUA_EXPR: case InvocationKind::LUA_EXPR:

View File

@@ -47,9 +47,9 @@ function bechar()
makeclass("engio") makeclass("engio")
function engio.myfunction(actor, place, a, b, c) function engio.myfunction(actor, place, a, b, c)
print("Myfunction actor=", actor," place=", place) print("Myfunction actor=", actor," place=", place)
pprint("A:", a) print("A:", a)
pprint("B:", b) print("B:", b)
pprint("C:", c) print("C:", c)
return {13, "chicken", {2,3,4}, false} return {13, "chicken", {2,3,4}, false}
end end