Skip to content

Commit 86f2a3f

Browse files
committed
add runIdleTasks
1 parent b3fbc1e commit 86f2a3f

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

build.zig.zon

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
.hash = "tigerbeetle_io-0.0.0-ViLgxpyRBAB5BMfIcj3KMXfbJzwARs9uSl8aRy2OXULd",
1414
},
1515
.v8 = .{
16-
.url = "https://github.com/lightpanda-io/zig-v8-fork/archive/23718cdb99aaa45105d0a7e0ca22587bf77d3b5f.tar.gz",
17-
.hash = "v8-0.0.0-xddH68m2AwDf42Qp2Udz4wTMVH8p71si7yLlUoZkPeEz",
16+
.url = "https://github.com/lightpanda-io/zig-v8-fork/archive/ef8defeefe31b32fc698cbc6539c80df11249b86.tar.gz",
17+
.hash = "v8-0.0.0-xddH68a4AwC8yjNL2ZOby7TfXXW5-mMV1_aj5AXoj3cy",
1818
},
1919
//.v8 = .{ .path = "../zig-v8-fork" },
2020
//.tigerbeetle_io = .{ .path = "../tigerbeetle-io" },

src/app.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const Notification = @import("notification.zig").Notification;
1414
pub const App = struct {
1515
loop: *Loop,
1616
config: Config,
17-
platform: *const Platform,
17+
platform: ?*const Platform,
1818
allocator: Allocator,
1919
telemetry: Telemetry,
2020
http_client: http.Client,
@@ -30,7 +30,7 @@ pub const App = struct {
3030

3131
pub const Config = struct {
3232
run_mode: RunMode,
33-
platform: *const Platform,
33+
platform: ?*const Platform = null,
3434
tls_verify_host: bool = true,
3535
http_proxy: ?std.Uri = null,
3636
proxy_type: ?http.ProxyType = null,

src/browser/browser.zig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,11 @@ pub const Browser = struct {
9797
}
9898

9999
pub fn runMicrotasks(self: *const Browser) void {
100+
self.env.runMicrotasks();
100101
while (self.env.pumpMessageLoop()) {
101102
log.debug(.browser, "pumpMessageLoop", .{});
102103
}
103-
return self.env.runMicrotasks();
104+
self.env.runIdleTasks();
104105
}
105106
};
106107

src/runtime/js.zig

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
156156
return struct {
157157
allocator: Allocator,
158158

159-
platform: *const Platform,
159+
platform: ?*const Platform,
160160

161161
// the global isolate
162162
isolate: v8.Isolate,
@@ -183,7 +183,7 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
183183

184184
const Opts = struct {};
185185

186-
pub fn init(allocator: Allocator, platform: *const Platform, _: Opts) !*Self {
186+
pub fn init(allocator: Allocator, platform: ?*const Platform, _: Opts) !*Self {
187187
// var params = v8.initCreateParams();
188188
var params = try allocator.create(v8.CreateParams);
189189
errdefer allocator.destroy(params);
@@ -264,7 +264,13 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
264264
}
265265

266266
pub fn pumpMessageLoop(self: *const Self) bool {
267-
return self.platform.inner.pumpMessageLoop(self.isolate, false);
267+
if (self.platform == null) return false;
268+
return self.platform.?.inner.pumpMessageLoop(self.isolate, false);
269+
}
270+
271+
pub fn runIdleTasks(self: *const Self) void {
272+
if (self.platform == null) return;
273+
return self.platform.?.inner.runIdleTasks(self.isolate, 1);
268274
}
269275

270276
pub fn newExecutionWorld(self: *Self) !ExecutionWorld {

0 commit comments

Comments
 (0)