Machinery for blocking http requests in place, except actual networking
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include "debugcollector.hpp"
|
||||
#include "printbuffer.hpp"
|
||||
#include "sched.hpp"
|
||||
#include "http.hpp"
|
||||
#include "source.hpp"
|
||||
#include "gui.hpp"
|
||||
#include "luasnap.hpp"
|
||||
@@ -188,6 +189,9 @@ public:
|
||||
// This is the primary dispatcher for all operations that mutate a world model.
|
||||
// To mutate a world model, create an invocation, then invoke it.
|
||||
//
|
||||
// It is legal to mutate a world model without using 'Invoke', but
|
||||
// only in authoritative world models.
|
||||
//
|
||||
void invoke(const Invocation &inv);
|
||||
|
||||
// Get the PrintBuffer of the actor.
|
||||
@@ -201,6 +205,14 @@ public:
|
||||
void update_source(const util::LuaSourcePtr &source);
|
||||
void update_source(const util::LuaSourceVec &source);
|
||||
|
||||
// Supply an HTTP response to an outstanding HTTP request.
|
||||
void http_response(int64_t request_id, const HttpInResponse &response);
|
||||
|
||||
// Abort all HTTP requests. This is typically used after
|
||||
// reloading a world from a save-game. The http requests that
|
||||
// were in progress are long-since dead.
|
||||
void abort_all_http_requests(int status_code, std::string_view error);
|
||||
|
||||
// Run all unit tests.
|
||||
//
|
||||
void run_unittests();
|
||||
@@ -216,6 +228,10 @@ public:
|
||||
//
|
||||
bool is_authoritative() const { return (world_type_ == util::WORLD_TYPE_MASTER) || (world_type_ == util::WORLD_TYPE_STANDALONE); }
|
||||
|
||||
// Get a table showing all outstanding HTTP requests.
|
||||
//
|
||||
const HttpOutRequestMap &http_requests() const { return http_requests_; }
|
||||
|
||||
// Serialize and deserialize.
|
||||
//
|
||||
void serialize(StreamBuffer *sb);
|
||||
@@ -263,6 +279,16 @@ public:
|
||||
//
|
||||
int64_t alloc_id_predictable();
|
||||
|
||||
// If we're in a probe, generate an error.
|
||||
// If we're in a nonauthoritative model, do a nopredict yield.
|
||||
// Otherwise, return.
|
||||
void guard_blockable(lua_State *L, const char *fn);
|
||||
|
||||
// If we're in a probe, return.
|
||||
// If we're in a nonauthoritative model, do a nopredict yield.
|
||||
// Otherwise, return.
|
||||
void guard_nopredict(lua_State *L, const char *fn);
|
||||
|
||||
private:
|
||||
// Add a thread to the scheduler queue.
|
||||
//
|
||||
@@ -478,6 +504,7 @@ private:
|
||||
eng::unordered_map<int64_t, UniqueTangible> tangibles_;
|
||||
|
||||
// Current time.
|
||||
//
|
||||
int64_t clock_;
|
||||
|
||||
// Thread schedule: must include every thread, except
|
||||
@@ -485,7 +512,13 @@ private:
|
||||
//
|
||||
Schedule thread_sched_;
|
||||
|
||||
// Outstanding HTTP requests, indexed by request ID.
|
||||
// Authoritative models only.
|
||||
//
|
||||
HttpOutRequestMap http_requests_;
|
||||
|
||||
// Serialized snapshot of world model.
|
||||
//
|
||||
StreamBuffer snapshot_;
|
||||
|
||||
// Redirects.
|
||||
@@ -513,6 +546,7 @@ private:
|
||||
friend int lfn_math_randomstate(lua_State *L);
|
||||
friend int lfn_wait(lua_State *L);
|
||||
friend int lfn_nopredict(lua_State *L);
|
||||
friend int lfn_http_get(lua_State *L);
|
||||
};
|
||||
|
||||
using UniqueWorld = std::unique_ptr<World>;
|
||||
|
||||
Reference in New Issue
Block a user