fix issues of LuaJIT/Node
This commit is contained in:
@@ -84,15 +84,18 @@ Thread::Handler Thread::CreateNodeLambdaHandler(
|
||||
case 0:
|
||||
th.ExecResume(L);
|
||||
return;
|
||||
case 2: {
|
||||
auto k = luaL_checkstring(L, 1);
|
||||
auto v = nf7::luajit::CheckValue(L, 2);
|
||||
caller->env().ExecSub(
|
||||
caller, [caller, callee, k = std::string {k}, v = std::move(v)]() {
|
||||
caller->Handle(k, v, callee);
|
||||
});
|
||||
th.ExecResume(L);
|
||||
} return;
|
||||
case 2:
|
||||
if (auto v = nf7::luajit::ToValue(L, 2)) {
|
||||
auto k = luaL_checkstring(L, 1);
|
||||
caller->env().ExecSub(
|
||||
caller, [caller, callee, k = std::string {k}, v = std::move(v)]() {
|
||||
caller->Handle(k, *v, callee);
|
||||
});
|
||||
th.ExecResume(L);
|
||||
return;
|
||||
} else {
|
||||
}
|
||||
/* FALLTHROUGH */
|
||||
default:
|
||||
if (auto log = th.logger()) {
|
||||
log->Warn("invalid use of yield, nf7:yield() or nf7:yield(name, value)");
|
||||
|
@@ -24,19 +24,16 @@ class NodeRootLambda final : public nf7::Node::Lambda,
|
||||
NodeRootLambda(NodeRootLambda&&) = delete;
|
||||
NodeRootLambda& operator=(const NodeRootLambda&) = delete;
|
||||
NodeRootLambda& operator=(NodeRootLambda&&) = delete;
|
||||
|
||||
bool KeepAlive() noexcept {
|
||||
if (target_.expired() && pro_.size()) {
|
||||
for (auto& pro : pro_) {
|
||||
pro.second.Throw(std::make_exception_ptr(
|
||||
nf7::Exception {"output was never satisified"}));
|
||||
}
|
||||
~NodeRootLambda() noexcept {
|
||||
target_ = nullptr;
|
||||
for (auto& pro : pro_) {
|
||||
pro.second.Throw(std::make_exception_ptr(
|
||||
nf7::Exception {"output was never satisified"}));
|
||||
}
|
||||
return !target_.expired();
|
||||
}
|
||||
|
||||
private:
|
||||
std::weak_ptr<nf7::Node::Lambda> target_;
|
||||
std::shared_ptr<nf7::Node::Lambda> target_;
|
||||
|
||||
std::unordered_map<std::string, nf7::Future<nf7::Value>::Promise> pro_;
|
||||
std::unordered_map<std::string, std::function<void(const nf7::Value&)>> handler_;
|
||||
|
Reference in New Issue
Block a user