Spooky hash, smarter animqueue diffs

This commit is contained in:
2021-07-18 17:48:39 -04:00
parent 4357fd647f
commit a39eb4a218
14 changed files with 645 additions and 197 deletions

View File

@@ -76,7 +76,6 @@ private:
std::vector<int64_t> salvaged_;
int64_t next_batch_;
int64_t next_id_;
int32_t queue_fill_;
friend int unittests_idalloc(lua_State *L);
public:
@@ -89,10 +88,10 @@ public:
~IdGlobalPool();
// Initialize the pool for use in a master model.
void init_master(int qf);
void init_master();
// Initialize the pool for use in a synchronous model.
void init_synch(int qf);
void init_synch();
// Create a single unique ID. Ids allocated this way are
// unlikely to be predicted correctly.
@@ -103,10 +102,6 @@ public:
// In a synchronous model, the batch is always zero (invalid).
int64_t get_batch();
// When a player pool refills its fifo queue, it refills it
// with this many batches.
int queue_fill() const { return queue_fill_; }
// Try to return the specified batch to the global pool.
// The salvage operation quietly does nothing if the batch is
// zero, or the batch contains fewer than 128 IDs.
@@ -128,7 +123,7 @@ public:
class IdPlayerPool {
private:
IdGlobalPool *global_;
bool fifo_enabled_;
int fifo_capacity_;
std::deque<int64_t> ranges_;
friend int unittests_idalloc(lua_State *L);
@@ -142,10 +137,9 @@ public:
IdPlayerPool(IdGlobalPool *g);
~IdPlayerPool();
// Enable or disable the fifo.
void enable_fifo();
void disable_fifo();
bool fifo_enabled() { return fifo_enabled_; }
// Set the fifo capacity. Max=255.
void set_fifo_capacity(int n);
int get_fifo_capacity() const { return fifo_capacity_; }
// Return all batches from the fifo to the global pool.
void unqueue();