mirror of
https://github.com/ziglang/zig.git
synced 2026-01-21 06:45:24 +00:00
enable event loop for ios, tvos, and watchos
This commit is contained in:
parent
fb366f3cd4
commit
ea23217751
@ -69,7 +69,7 @@ pub const Loop = struct {
|
||||
};
|
||||
|
||||
pub const EventFd = switch (builtin.os.tag) {
|
||||
.macos, .freebsd, .netbsd, .dragonfly, .openbsd => KEventFd,
|
||||
.macos, .ios, .tvos, .watchos, .freebsd, .netbsd, .dragonfly, .openbsd => KEventFd,
|
||||
.linux => struct {
|
||||
base: ResumeNode,
|
||||
epoll_op: u32,
|
||||
@ -88,7 +88,7 @@ pub const Loop = struct {
|
||||
};
|
||||
|
||||
pub const Basic = switch (builtin.os.tag) {
|
||||
.macos, .freebsd, .netbsd, .dragonfly, .openbsd => KEventBasic,
|
||||
.macos, .ios, .tvos, .watchos, .freebsd, .netbsd, .dragonfly, .openbsd => KEventBasic,
|
||||
.linux => struct {
|
||||
base: ResumeNode,
|
||||
},
|
||||
@ -269,7 +269,7 @@ pub const Loop = struct {
|
||||
self.extra_threads[extra_thread_index] = try Thread.spawn(.{}, workerRun, .{self});
|
||||
}
|
||||
},
|
||||
.macos, .freebsd, .netbsd, .dragonfly => {
|
||||
.macos, .ios, .tvos, .watchos, .freebsd, .netbsd, .dragonfly => {
|
||||
self.os_data.kqfd = try os.kqueue();
|
||||
errdefer os.close(self.os_data.kqfd);
|
||||
|
||||
@ -457,7 +457,7 @@ pub const Loop = struct {
|
||||
while (self.available_eventfd_resume_nodes.pop()) |node| os.close(node.data.eventfd);
|
||||
os.close(self.os_data.epollfd);
|
||||
},
|
||||
.macos, .freebsd, .netbsd, .dragonfly, .openbsd => {
|
||||
.macos, .ios, .tvos, .watchos, .freebsd, .netbsd, .dragonfly, .openbsd => {
|
||||
os.close(self.os_data.kqfd);
|
||||
},
|
||||
.windows => {
|
||||
@ -552,7 +552,7 @@ pub const Loop = struct {
|
||||
.linux => {
|
||||
self.linuxWaitFd(fd, os.linux.EPOLL.ET | os.linux.EPOLL.ONESHOT | os.linux.EPOLL.IN);
|
||||
},
|
||||
.macos, .freebsd, .netbsd, .dragonfly, .openbsd => {
|
||||
.macos, .ios, .tvos, .watchos, .freebsd, .netbsd, .dragonfly, .openbsd => {
|
||||
self.bsdWaitKev(@intCast(usize, fd), os.system.EVFILT_READ, os.system.EV_ONESHOT);
|
||||
},
|
||||
else => @compileError("Unsupported OS"),
|
||||
@ -564,7 +564,7 @@ pub const Loop = struct {
|
||||
.linux => {
|
||||
self.linuxWaitFd(fd, os.linux.EPOLL.ET | os.linux.EPOLL.ONESHOT | os.linux.EPOLL.OUT);
|
||||
},
|
||||
.macos, .freebsd, .netbsd, .dragonfly, .openbsd => {
|
||||
.macos, .ios, .tvos, .watchos, .freebsd, .netbsd, .dragonfly, .openbsd => {
|
||||
self.bsdWaitKev(@intCast(usize, fd), os.system.EVFILT_WRITE, os.system.EV_ONESHOT);
|
||||
},
|
||||
else => @compileError("Unsupported OS"),
|
||||
@ -576,7 +576,7 @@ pub const Loop = struct {
|
||||
.linux => {
|
||||
self.linuxWaitFd(fd, os.linux.EPOLL.ET | os.linux.EPOLL.ONESHOT | os.linux.EPOLL.OUT | os.linux.EPOLL.IN);
|
||||
},
|
||||
.macos, .freebsd, .netbsd, .dragonfly, .openbsd => {
|
||||
.macos, .ios, .tvos, .watchos, .freebsd, .netbsd, .dragonfly, .openbsd => {
|
||||
self.bsdWaitKev(@intCast(usize, fd), os.system.EVFILT_READ, os.system.EV_ONESHOT);
|
||||
self.bsdWaitKev(@intCast(usize, fd), os.system.EVFILT_WRITE, os.system.EV_ONESHOT);
|
||||
},
|
||||
@ -645,7 +645,7 @@ pub const Loop = struct {
|
||||
const eventfd_node = &resume_stack_node.data;
|
||||
eventfd_node.base.handle = next_tick_node.data;
|
||||
switch (builtin.os.tag) {
|
||||
.macos, .freebsd, .netbsd, .dragonfly, .openbsd => {
|
||||
.macos, .ios, .tvos, .watchos, .freebsd, .netbsd, .dragonfly, .openbsd => {
|
||||
const kevent_array = @as(*const [1]os.Kevent, &eventfd_node.kevent);
|
||||
const empty_kevs = &[0]os.Kevent{};
|
||||
_ = os.kevent(self.os_data.kqfd, kevent_array, empty_kevs, null) catch {
|
||||
@ -708,6 +708,9 @@ pub const Loop = struct {
|
||||
switch (builtin.os.tag) {
|
||||
.linux,
|
||||
.macos,
|
||||
.ios,
|
||||
.tvos,
|
||||
.watchos,
|
||||
.freebsd,
|
||||
.netbsd,
|
||||
.dragonfly,
|
||||
@ -802,7 +805,7 @@ pub const Loop = struct {
|
||||
}
|
||||
return;
|
||||
},
|
||||
.macos, .freebsd, .netbsd, .dragonfly, .openbsd => {
|
||||
.macos, .ios, .tvos, .watchos, .freebsd, .netbsd, .dragonfly, .openbsd => {
|
||||
const final_kevent = @as(*const [1]os.Kevent, &self.os_data.final_kevent);
|
||||
const empty_kevs = &[0]os.Kevent{};
|
||||
// cannot fail because we already added it and this just enables it
|
||||
@ -1428,7 +1431,7 @@ pub const Loop = struct {
|
||||
}
|
||||
}
|
||||
},
|
||||
.macos, .freebsd, .netbsd, .dragonfly, .openbsd => {
|
||||
.macos, .ios, .tvos, .watchos, .freebsd, .netbsd, .dragonfly, .openbsd => {
|
||||
var eventlist: [1]os.Kevent = undefined;
|
||||
const empty_kevs = &[0]os.Kevent{};
|
||||
const count = os.kevent(self.os_data.kqfd, empty_kevs, eventlist[0..], null) catch unreachable;
|
||||
@ -1554,7 +1557,7 @@ pub const Loop = struct {
|
||||
|
||||
const OsData = switch (builtin.os.tag) {
|
||||
.linux => LinuxOsData,
|
||||
.macos, .freebsd, .netbsd, .dragonfly, .openbsd => KEventData,
|
||||
.macos, .ios, .tvos, .watchos, .freebsd, .netbsd, .dragonfly, .openbsd => KEventData,
|
||||
.windows => struct {
|
||||
io_port: windows.HANDLE,
|
||||
extra_thread_count: usize,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user