Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions lute/runtime/include/lute/runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

#include "Luau/Variant.h"
#include "lute/ref.h"

#include "uv.h"
#include <atomic>
#include <condition_variable>
#include <functional>
#include <memory>
#include <mutex>
#include <string>
#include <thread>
#include <vector>

struct lua_State;
Expand Down Expand Up @@ -46,9 +44,6 @@ struct Runtime
bool runToCompletion();
RuntimeStep runOnce();

// For child runtimes, run a thread waiting for work
void runContinuously();

// Reports an error for a specified lua state.
void reportError(lua_State* L);

Expand All @@ -70,6 +65,9 @@ struct Runtime
void addPendingToken();
void releasePendingToken();

// Process queued continuations (called by uv_async callback)
void processContinuations();

// VM for this runtime
std::unique_ptr<lua_State, void (*)(lua_State*)> globalState;

Expand All @@ -85,12 +83,11 @@ struct Runtime
std::mutex continuationMutex;
std::vector<std::function<void()>> continuations;

// TODO: can this be handled by libuv?
std::atomic<bool> stop;
std::condition_variable runLoopCv;
std::thread runLoopThread;

std::atomic<int> activeTokens;
std::atomic<bool> errorOccurred{false};

uv_async_t asyncHandle;
bool asyncInitialized = false;
};

Runtime* getRuntime(lua_State* L);
Expand Down
Loading