aboutsummaryrefslogtreecommitdiff
path: root/src/lanes.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/lanes.cpp43
1 files changed, 2 insertions, 41 deletions
diff --git a/src/lanes.cpp b/src/lanes.cpp
index b74e9ec..4b4f9a8 100644
--- a/src/lanes.cpp
+++ b/src/lanes.cpp
@@ -637,50 +637,11 @@ LUAG_FUNC(configure)
637 DEBUGSPEW_CODE(DebugSpewIndentScope _scope{ _U }); 637 DEBUGSPEW_CODE(DebugSpewIndentScope _scope{ _U });
638 638
639 if (_U == nullptr) { 639 if (_U == nullptr) {
640 _U = Universe::Create(L_); // L_: settings universe
641 DEBUGSPEW_CODE(DebugSpewIndentScope _scope2{ _U });
642 lua_createtable(L_, 0, 1); // L_: settings universe {mt}
643 std::ignore = luaG_getfield(L_, 1, "shutdown_timeout"); // L_: settings universe {mt} shutdown_timeout
644 std::ignore = luaG_getfield(L_, 1, "shutdown_mode"); // L_: settings universe {mt} shutdown_timeout shutdown_mode
645 lua_pushcclosure(L_, LG_universe_gc, 2); // L_: settings universe {mt} LG_universe_gc
646 lua_setfield(L_, -2, "__gc"); // L_: settings universe {mt}
647 lua_setmetatable(L_, -2); // L_: settings universe
648 lua_pop(L_, 1); // L_: settings
649 std::ignore = luaG_getfield(L_, 1, "verbose_errors"); // L_: settings verbose_errors
650 _U->verboseErrors = lua_toboolean(L_, -1) ? true : false;
651 lua_pop(L_, 1); // L_: settings
652 std::ignore = luaG_getfield(L_, 1, "demote_full_userdata"); // L_: settings demote_full_userdata
653 _U->demoteFullUserdata = lua_toboolean(L_, -1) ? true : false;
654 lua_pop(L_, 1); // L_: settings
655
656 // tracking
657 std::ignore = luaG_getfield(L_, 1, "track_lanes"); // L_: settings track_lanes
658 if (lua_toboolean(L_, -1)) {
659 _U->tracker.activate();
660 }
661 lua_pop(L_, 1); // L_: settings
662
663 // Linked chains handling
664 _U->selfdestructFirst = SELFDESTRUCT_END;
665 _U->initializeAllocatorFunction(L_);
666 state::InitializeOnStateCreate(_U, L_);
667 _U->initializeKeepers(L_);
668 STACK_CHECK(L_, 1);
669
670 // Initialize 'timerLinda'; a common Linda object shared by all states
671 lua_pushcfunction(L_, LG_linda); // L_: settings lanes.linda
672 lua_pushliteral(L_, "lanes-timer"); // L_: settings lanes.linda "lanes-timer"
673 lua_call(L_, 1, 1); // L_: settings linda
674 STACK_CHECK(L_, 2);
675
676 // Proxy userdata contents is only a 'DeepPrelude*' pointer
677 _U->timerLinda = *lua_tofulluserdata<DeepPrelude*>(L_, -1);
678 // increment refcount so that this linda remains alive as long as the universe exists.
679 _U->timerLinda->refcount.fetch_add(1, std::memory_order_relaxed);
680 lua_pop(L_, 1); // L_: settings
681 // store a hidden reference in the registry to make sure the string is kept around even if a lane decides to manually change the "decoda_name" global... 640 // store a hidden reference in the registry to make sure the string is kept around even if a lane decides to manually change the "decoda_name" global...
682 kLaneNameRegKey.setValue(L_, [](lua_State* L_) { std::ignore = lua_pushstringview(L_, "main"); }); 641 kLaneNameRegKey.setValue(L_, [](lua_State* L_) { std::ignore = lua_pushstringview(L_, "main"); });
683 642
643 // create the universe
644 _U = Universe::Create(L_); // L_: settings universe
684 } 645 }
685 STACK_CHECK(L_, 1); 646 STACK_CHECK(L_, 1);
686 647