Initial revision of animqueue

This commit is contained in:
2021-01-12 14:14:38 -05:00
parent 78f8610eb8
commit 25b9b4cb5d
18 changed files with 785 additions and 308 deletions

View File

@@ -99,7 +99,9 @@ void IdPlayerPool::purge() {
void IdPlayerPool::refill() {
while (int(ranges_.size()) < global_->queue_fill()) {
ranges_.push_back(global_->get_batch());
int64_t batch = global_->get_batch();
if (batch == 0) break;
ranges_.push_back(batch);
}
}
@@ -112,11 +114,17 @@ void IdPlayerPool::unqueue() {
int64_t IdPlayerPool::get_batch() {
while (int(ranges_.size()) < global_->queue_fill() + 1) {
ranges_.push_back(global_->get_batch());
int64_t batch = global_->get_batch();
if (batch == 0) break;
ranges_.push_back(batch);
}
if (ranges_.empty()) {
return 0;
} else {
int64_t batch = ranges_.front();
ranges_.pop_front();
return batch;
}
int64_t batch = ranges_.front();
ranges_.pop_front();
return batch;
}
void IdPlayerPool::salvage_thread(lua_State *L) {
@@ -184,6 +192,15 @@ LuaDefine(cunittests_idalloc, "c") {
gp.salvage(nthbatch(142) + 145);
assert(gp.get_batch() == nthbatch(2));
// In the synchronous model, refill should do nothing.
pp.purge();
gp.init_synch(3);
pp.refill();
assert(pp.size() == 0);
assert(pp.get_batch() == 0);
assert(pp.size() == 0);
assert(pp.get_batch() == 0);
// Test refill from master.
pp.purge();
gp.init_master(3);