Added a thread queue

This commit is contained in:
2021-02-18 14:56:12 -05:00
parent 213bf12425
commit 1dcf0494ef
4 changed files with 100 additions and 21 deletions

View File

@@ -9,6 +9,8 @@
#include "source.hpp"
#include "gui.hpp"
#include "luasnap.hpp"
#include <set>
#include <utility>
#include <memory>
#include <unordered_map>
@@ -44,6 +46,10 @@ public:
class World {
public:
// A thread ID appended to a place ID.
//
using ThreadPair = std::pair<int64_t, int64_t>;
// A lua intepreter with snapshot function.
//
LuaSnap lua_snap_;
@@ -58,6 +64,14 @@ public:
PlaneMap plane_map_;
std::unordered_map<int64_t, Tangible> tangibles_;
// Thread queue.
//
std::set<ThreadPair> thread_queue_;
void enqueue_thread(int64_t tid, int64_t place_id);
void run_thread_queue();
void run_thread(int64_t tid, int64_t place_id);
public:
// Constructor.
//
@@ -114,7 +128,9 @@ public:
// Invoke an action plan.
//
void invoke_plan(int64_t actor_id, int64_t place_id, const std::string &action, Gui *gui);
// Eventually we'll add another parameter for gui-state.
//
void invoke_plan(int64_t actor_id, int64_t place_id, const std::string &action);
// fetch
//