remove memory pool usage for mac

This commit is contained in:
Mitchell Hashimoto
2023-02-22 15:32:30 -08:00
parent 053748481a
commit 8c18e1ee48
2 changed files with 3 additions and 13 deletions

View File

@ -23,7 +23,6 @@ const DevMode = @import("DevMode.zig");
const log = std.log.scoped(.app);
const SurfaceList = std.ArrayListUnmanaged(*apprt.Surface);
const SurfacePool = std.heap.MemoryPool(apprt.Surface);
/// The type used for sending messages to the app thread.
pub const Mailbox = BlockingQueue(Message, 64);
@ -34,12 +33,6 @@ alloc: Allocator,
/// The list of surfaces that are currently active.
surfaces: SurfaceList,
/// The memory pool to request surfaces. We use a memory pool because surfaces
/// typically require stable pointers due to runtime GUI callbacks. Centralizing
/// all the allocations in this pool makes it so that all our pools remain
/// close in memory.
surface_pool: SurfacePool,
// The configuration for the app.
config: *const Config,
@ -72,13 +65,11 @@ pub fn create(
app.* = .{
.alloc = alloc,
.surfaces = .{},
.surface_pool = try SurfacePool.initPreheated(alloc, 2),
.config = config,
.mailbox = mailbox,
.quit = false,
};
errdefer app.surfaces.deinit(alloc);
errdefer app.surface_pool.deinit();
return app;
}
@ -87,7 +78,6 @@ pub fn destroy(self: *App) void {
// Clean up all our surfaces
for (self.surfaces.items) |surface| surface.deinit();
self.surfaces.deinit(self.alloc);
self.surface_pool.deinit();
self.mailbox.destroy(self.alloc);
self.alloc.destroy(self);

View File

@ -78,8 +78,8 @@ pub const App = struct {
/// Create a new window for the app.
pub fn newWindow(self: *App) !*Surface {
// Grab a surface allocation because we're going to need it.
const surface = try self.app.surface_pool.create();
errdefer self.app.surface_pool.destroy(surface);
var surface = try self.app.alloc.create(Surface);
errdefer self.app.alloc.destroy(surface);
// Create the surface -- because windows are surfaces for glfw.
try surface.init(self);
@ -125,7 +125,7 @@ pub const App = struct {
/// Close the given surface.
pub fn closeSurface(self: *App, surface: *Surface) void {
surface.deinit();
self.app.surface_pool.destroy(surface);
self.app.alloc.destroy(surface);
}
fn glfwErrorCallback(code: glfw.ErrorCode, desc: [:0]const u8) void {