Added class Schedule for threads

This commit is contained in:
2021-02-18 17:21:25 -05:00
parent d931191901
commit 36ff4eacae
5 changed files with 113 additions and 64 deletions

View File

@@ -6,6 +6,7 @@
#include "planemap.hpp"
#include "idalloc.hpp"
#include "animqueue.hpp"
#include "sched.hpp"
#include "source.hpp"
#include "gui.hpp"
#include "luasnap.hpp"
@@ -46,10 +47,6 @@ 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_;
@@ -64,14 +61,12 @@ public:
PlaneMap plane_map_;
std::unordered_map<int64_t, Tangible> tangibles_;
// Thread queue.
// Thread schedule: should include every thread, except
// for the one currently-executing thread.
//
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);
Schedule thread_sched_;
void run_scheduled_threads(int64_t clk);
public:
// Constructor.
//