-
Notifications
You must be signed in to change notification settings - Fork 35
Fix vm.create child VMs missing native libs and make spawned runtimes libuv-safe
#692
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: primary
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -14,6 +14,7 @@ | |||||
| #include <vector> | ||||||
|
|
||||||
| struct lua_State; | ||||||
| struct uv_loop_s; | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is an internal libuv type - you'll want to store |
||||||
|
|
||||||
| struct ThreadToContinue | ||||||
| { | ||||||
|
|
@@ -44,6 +45,9 @@ struct Runtime | |||||
| Runtime(); | ||||||
| ~Runtime(); | ||||||
|
|
||||||
| bool useDedicatedUvLoop(); | ||||||
| uv_loop_s* getUvLoop() const; | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| bool runToCompletion(); | ||||||
| RuntimeStep runOnce(); | ||||||
|
|
||||||
|
|
@@ -77,6 +81,9 @@ struct Runtime | |||||
| // Shorthand for global state | ||||||
| lua_State* GL = nullptr; | ||||||
|
|
||||||
| // Event loop for this runtime; defaults to `uv_default_loop()`, but can be dedicated via `useDedicatedUvLoop`. | ||||||
| uv_loop_s* uvLoop = nullptr; | ||||||
|
Comment on lines
+84
to
+85
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This adds a lot of complexity. Instead of defaulting, just initialize a |
||||||
|
|
||||||
| std::mutex dataCopyMutex; | ||||||
| std::unique_ptr<lua_State, void (*)(lua_State*)> dataCopy; | ||||||
|
|
||||||
|
|
@@ -92,6 +99,8 @@ struct Runtime | |||||
| std::thread runLoopThread; | ||||||
|
|
||||||
| std::atomic<int> activeTokens; | ||||||
|
|
||||||
| bool ownsUvLoop = false; | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could do one runtime, one loop - see my comment below, since we might not actually need this? |
||||||
| }; | ||||||
|
|
||||||
| Runtime* getRuntime(lua_State* L); | ||||||
|
|
@@ -114,3 +123,7 @@ struct ResumeTokenData | |||||
| ResumeToken getResumeToken(lua_State* L); | ||||||
|
|
||||||
| lua_State* setupState(Runtime& runtime, std::function<void(lua_State*)> doBeforeSandbox); | ||||||
|
|
||||||
| // Track child runtimes created via `@lute/vm` so the CLI can stay alive when they have work (e.g. servers). | ||||||
| void registerSpawnedRuntime(const std::shared_ptr<Runtime>& runtime); | ||||||
| void waitForSpawnedRuntimes(); | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably don't want to re-interpret cast here - this should just be a uv_loop_t.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.