default:
assert(false);
}
+
+ if (ud->generation != generation) {
+ auto it = lingering_generations.find(ud->generation);
+ assert(it != lingering_generations.end());
+ if (--it->second.num_frames_left == 0) {
+ lingering_generations.erase(it); // Deallocates the userdata block.
+ }
+ }
}
//static int sumsum = 0;
return;
}
+ lock_guard<mutex> lock(freelist_mutex);
+ lingering_generations[generation] = LingeringGeneration{ move(userdata), this->num_queued_frames };
+ ++generation;
+
+ while (!freelist.empty()) {
+ Frame frame = freelist.front();
+ freelist.pop();
+ destroy_frame(&frame);
+ }
+
this->pixel_format = pixel_format;
this->frame_size = frame_size;
this->width = width;
this->permissions = permissions;
this->map_bits = map_bits;
- lock_guard<mutex> lock(freelist_mutex);
- while (!freelist.empty()) {
- Frame frame = freelist.front();
- freelist.pop();
- destroy_frame(&frame);
- }
- ++generation;
+ userdata.reset(new Userdata[num_queued_frames]);
for (size_t i = 0; i < num_queued_frames; ++i) {
init_frame(i, frame_size, width, height, permissions, map_bits, generation);
}