mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 23:23:28 +00:00
add runIdleTasks
This commit is contained in:
@@ -14,7 +14,7 @@ const Notification = @import("notification.zig").Notification;
|
|||||||
pub const App = struct {
|
pub const App = struct {
|
||||||
loop: *Loop,
|
loop: *Loop,
|
||||||
config: Config,
|
config: Config,
|
||||||
platform: *const Platform,
|
platform: ?*const Platform,
|
||||||
allocator: Allocator,
|
allocator: Allocator,
|
||||||
telemetry: Telemetry,
|
telemetry: Telemetry,
|
||||||
http_client: http.Client,
|
http_client: http.Client,
|
||||||
@@ -30,7 +30,7 @@ pub const App = struct {
|
|||||||
|
|
||||||
pub const Config = struct {
|
pub const Config = struct {
|
||||||
run_mode: RunMode,
|
run_mode: RunMode,
|
||||||
platform: *const Platform,
|
platform: ?*const Platform = null,
|
||||||
tls_verify_host: bool = true,
|
tls_verify_host: bool = true,
|
||||||
http_proxy: ?std.Uri = null,
|
http_proxy: ?std.Uri = null,
|
||||||
proxy_type: ?http.ProxyType = null,
|
proxy_type: ?http.ProxyType = null,
|
||||||
|
|||||||
@@ -97,10 +97,11 @@ pub const Browser = struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn runMicrotasks(self: *const Browser) void {
|
pub fn runMicrotasks(self: *const Browser) void {
|
||||||
|
self.env.runMicrotasks();
|
||||||
while (self.env.pumpMessageLoop()) {
|
while (self.env.pumpMessageLoop()) {
|
||||||
log.debug(.browser, "pumpMessageLoop", .{});
|
log.debug(.browser, "pumpMessageLoop", .{});
|
||||||
}
|
}
|
||||||
return self.env.runMicrotasks();
|
self.env.runIdleTasks();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
|
|||||||
return struct {
|
return struct {
|
||||||
allocator: Allocator,
|
allocator: Allocator,
|
||||||
|
|
||||||
platform: *const Platform,
|
platform: ?*const Platform,
|
||||||
|
|
||||||
// the global isolate
|
// the global isolate
|
||||||
isolate: v8.Isolate,
|
isolate: v8.Isolate,
|
||||||
@@ -183,7 +183,7 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
|
|||||||
|
|
||||||
const Opts = struct {};
|
const Opts = struct {};
|
||||||
|
|
||||||
pub fn init(allocator: Allocator, platform: *const Platform, _: Opts) !*Self {
|
pub fn init(allocator: Allocator, platform: ?*const Platform, _: Opts) !*Self {
|
||||||
// var params = v8.initCreateParams();
|
// var params = v8.initCreateParams();
|
||||||
var params = try allocator.create(v8.CreateParams);
|
var params = try allocator.create(v8.CreateParams);
|
||||||
errdefer allocator.destroy(params);
|
errdefer allocator.destroy(params);
|
||||||
@@ -274,7 +274,13 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn pumpMessageLoop(self: *const Self) bool {
|
pub fn pumpMessageLoop(self: *const Self) bool {
|
||||||
return self.platform.inner.pumpMessageLoop(self.isolate, false);
|
if (self.platform == null) return false;
|
||||||
|
return self.platform.?.inner.pumpMessageLoop(self.isolate, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn runIdleTasks(self: *const Self) void {
|
||||||
|
if (self.platform == null) return;
|
||||||
|
return self.platform.?.inner.runIdleTasks(self.isolate, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn newExecutionWorld(self: *Self) !ExecutionWorld {
|
pub fn newExecutionWorld(self: *Self) !ExecutionWorld {
|
||||||
|
|||||||
Reference in New Issue
Block a user