aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/rare_data.zig
diff options
context:
space:
mode:
authorGravatar dave caruso <me@paperdave.net> 2023-09-05 17:41:39 -0700
committerGravatar GitHub <noreply@github.com> 2023-09-05 17:41:39 -0700
commitacfd028e8f859a0e8139b7adab5d319e326c2373 (patch)
treef6bf98b2e40fcbcc036348bf7e0556e9edfa3b4e /src/bun.js/rare_data.zig
parent6f8a3934923198cbadae64cda24201e2de2655c1 (diff)
downloadbun-acfd028e8f859a0e8139b7adab5d319e326c2373.tar.gz
bun-acfd028e8f859a0e8139b7adab5d319e326c2373.tar.zst
bun-acfd028e8f859a0e8139b7adab5d319e326c2373.zip
feat(runtime): Implement `fs.watchFile` (#4467)
* really lame prototype * uses threads but badly * it works i guess * unwatchFile but lame * it works * test * a * aomitcs * fix unwatching race condition * use hasPendingActivity and GC stuff better * test * revert this
Diffstat (limited to 'src/bun.js/rare_data.zig')
-rw-r--r--src/bun.js/rare_data.zig10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/bun.js/rare_data.zig b/src/bun.js/rare_data.zig
index 78354676f..706826033 100644
--- a/src/bun.js/rare_data.zig
+++ b/src/bun.js/rare_data.zig
@@ -10,6 +10,7 @@ const BoringSSL = @import("root").bun.BoringSSL;
const bun = @import("root").bun;
const WebSocketClientMask = @import("../http/websocket_http_client.zig").Mask;
const UUID = @import("./uuid.zig");
+const StatWatcherScheduler = @import("./node/node_fs_stat_watcher.zig").StatWatcherScheduler;
boring_ssl_engine: ?*BoringSSL.ENGINE = null,
editor_context: EditorContext = EditorContext{},
@@ -32,6 +33,8 @@ global_dns_data: ?*JSC.DNS.GlobalData = null,
mime_types: ?bun.HTTP.MimeType.Map = null,
+node_fs_stat_watcher_scheduler: ?*StatWatcherScheduler = null,
+
pub fn hotMap(this: *RareData, allocator: std.mem.Allocator) *HotMap {
if (this.hot_map == null) {
this.hot_map = HotMap.init(allocator);
@@ -314,3 +317,10 @@ pub fn globalDNSResolver(rare: *RareData, vm: *JSC.VirtualMachine) *JSC.DNS.DNSR
return &rare.global_dns_data.?.resolver;
}
+
+pub fn nodeFSStatWatcherScheduler(rare: *RareData, vm: *JSC.VirtualMachine) *StatWatcherScheduler {
+ return rare.node_fs_stat_watcher_scheduler orelse {
+ rare.node_fs_stat_watcher_scheduler = StatWatcherScheduler.init(vm.allocator, vm);
+ return rare.node_fs_stat_watcher_scheduler.?;
+ };
+}