Initial revision of animqueue
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user