mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 08:46:08 +03:00
remove memory pool usage for mac
This commit is contained in:
10
src/App.zig
10
src/App.zig
@ -23,7 +23,6 @@ const DevMode = @import("DevMode.zig");
|
|||||||
const log = std.log.scoped(.app);
|
const log = std.log.scoped(.app);
|
||||||
|
|
||||||
const SurfaceList = std.ArrayListUnmanaged(*apprt.Surface);
|
const SurfaceList = std.ArrayListUnmanaged(*apprt.Surface);
|
||||||
const SurfacePool = std.heap.MemoryPool(apprt.Surface);
|
|
||||||
|
|
||||||
/// The type used for sending messages to the app thread.
|
/// The type used for sending messages to the app thread.
|
||||||
pub const Mailbox = BlockingQueue(Message, 64);
|
pub const Mailbox = BlockingQueue(Message, 64);
|
||||||
@ -34,12 +33,6 @@ alloc: Allocator,
|
|||||||
/// The list of surfaces that are currently active.
|
/// The list of surfaces that are currently active.
|
||||||
surfaces: SurfaceList,
|
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.
|
// The configuration for the app.
|
||||||
config: *const Config,
|
config: *const Config,
|
||||||
|
|
||||||
@ -72,13 +65,11 @@ pub fn create(
|
|||||||
app.* = .{
|
app.* = .{
|
||||||
.alloc = alloc,
|
.alloc = alloc,
|
||||||
.surfaces = .{},
|
.surfaces = .{},
|
||||||
.surface_pool = try SurfacePool.initPreheated(alloc, 2),
|
|
||||||
.config = config,
|
.config = config,
|
||||||
.mailbox = mailbox,
|
.mailbox = mailbox,
|
||||||
.quit = false,
|
.quit = false,
|
||||||
};
|
};
|
||||||
errdefer app.surfaces.deinit(alloc);
|
errdefer app.surfaces.deinit(alloc);
|
||||||
errdefer app.surface_pool.deinit();
|
|
||||||
|
|
||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
@ -87,7 +78,6 @@ pub fn destroy(self: *App) void {
|
|||||||
// Clean up all our surfaces
|
// Clean up all our surfaces
|
||||||
for (self.surfaces.items) |surface| surface.deinit();
|
for (self.surfaces.items) |surface| surface.deinit();
|
||||||
self.surfaces.deinit(self.alloc);
|
self.surfaces.deinit(self.alloc);
|
||||||
self.surface_pool.deinit();
|
|
||||||
self.mailbox.destroy(self.alloc);
|
self.mailbox.destroy(self.alloc);
|
||||||
|
|
||||||
self.alloc.destroy(self);
|
self.alloc.destroy(self);
|
||||||
|
@ -78,8 +78,8 @@ pub const App = struct {
|
|||||||
/// Create a new window for the app.
|
/// Create a new window for the app.
|
||||||
pub fn newWindow(self: *App) !*Surface {
|
pub fn newWindow(self: *App) !*Surface {
|
||||||
// Grab a surface allocation because we're going to need it.
|
// Grab a surface allocation because we're going to need it.
|
||||||
const surface = try self.app.surface_pool.create();
|
var surface = try self.app.alloc.create(Surface);
|
||||||
errdefer self.app.surface_pool.destroy(surface);
|
errdefer self.app.alloc.destroy(surface);
|
||||||
|
|
||||||
// Create the surface -- because windows are surfaces for glfw.
|
// Create the surface -- because windows are surfaces for glfw.
|
||||||
try surface.init(self);
|
try surface.init(self);
|
||||||
@ -125,7 +125,7 @@ pub const App = struct {
|
|||||||
/// Close the given surface.
|
/// Close the given surface.
|
||||||
pub fn closeSurface(self: *App, surface: *Surface) void {
|
pub fn closeSurface(self: *App, surface: *Surface) void {
|
||||||
surface.deinit();
|
surface.deinit();
|
||||||
self.app.surface_pool.destroy(surface);
|
self.app.alloc.destroy(surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn glfwErrorCallback(code: glfw.ErrorCode, desc: [:0]const u8) void {
|
fn glfwErrorCallback(code: glfw.ErrorCode, desc: [:0]const u8) void {
|
||||||
|
Reference in New Issue
Block a user