mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
std.Io.Threaded: import std.mem.Alignment
This commit is contained in:
parent
d3e20e71be
commit
fba9fdf54f
@ -13,6 +13,7 @@ const net = std.Io.net;
|
||||
const HostName = std.Io.net.HostName;
|
||||
const IpAddress = std.Io.net.IpAddress;
|
||||
const Allocator = std.mem.Allocator;
|
||||
const Alignment = std.mem.Alignment;
|
||||
const assert = std.debug.assert;
|
||||
const posix = std.posix;
|
||||
|
||||
@ -387,7 +388,7 @@ const AsyncClosure = struct {
|
||||
func: *const fn (context: *anyopaque, result: *anyopaque) void,
|
||||
reset_event: ResetEvent,
|
||||
select_condition: ?*ResetEvent,
|
||||
context_alignment: std.mem.Alignment,
|
||||
context_alignment: Alignment,
|
||||
result_offset: usize,
|
||||
alloc_len: usize,
|
||||
|
||||
@ -434,9 +435,9 @@ const AsyncClosure = struct {
|
||||
gpa: Allocator,
|
||||
mode: enum { async, concurrent },
|
||||
result_len: usize,
|
||||
result_alignment: std.mem.Alignment,
|
||||
result_alignment: Alignment,
|
||||
context: []const u8,
|
||||
context_alignment: std.mem.Alignment,
|
||||
context_alignment: Alignment,
|
||||
func: *const fn (context: *const anyopaque, result: *anyopaque) void,
|
||||
) Allocator.Error!*AsyncClosure {
|
||||
const max_context_misalignment = context_alignment.toByteUnits() -| @alignOf(AsyncClosure);
|
||||
@ -485,9 +486,9 @@ const AsyncClosure = struct {
|
||||
fn async(
|
||||
userdata: ?*anyopaque,
|
||||
result: []u8,
|
||||
result_alignment: std.mem.Alignment,
|
||||
result_alignment: Alignment,
|
||||
context: []const u8,
|
||||
context_alignment: std.mem.Alignment,
|
||||
context_alignment: Alignment,
|
||||
start: *const fn (context: *const anyopaque, result: *anyopaque) void,
|
||||
) ?*Io.AnyFuture {
|
||||
if (builtin.single_threaded) {
|
||||
@ -547,9 +548,9 @@ fn async(
|
||||
fn concurrent(
|
||||
userdata: ?*anyopaque,
|
||||
result_len: usize,
|
||||
result_alignment: std.mem.Alignment,
|
||||
result_alignment: Alignment,
|
||||
context: []const u8,
|
||||
context_alignment: std.mem.Alignment,
|
||||
context_alignment: Alignment,
|
||||
start: *const fn (context: *const anyopaque, result: *anyopaque) void,
|
||||
) Io.ConcurrentError!*Io.AnyFuture {
|
||||
if (builtin.single_threaded) return error.ConcurrencyUnavailable;
|
||||
@ -597,7 +598,7 @@ const GroupClosure = struct {
|
||||
/// Points to sibling `GroupClosure`. Used for walking the group to cancel all.
|
||||
node: std.SinglyLinkedList.Node,
|
||||
func: *const fn (*Io.Group, context: *anyopaque) void,
|
||||
context_alignment: std.mem.Alignment,
|
||||
context_alignment: Alignment,
|
||||
alloc_len: usize,
|
||||
|
||||
fn start(closure: *Closure) void {
|
||||
@ -638,7 +639,7 @@ const GroupClosure = struct {
|
||||
t: *Threaded,
|
||||
group: *Io.Group,
|
||||
context: []const u8,
|
||||
context_alignment: std.mem.Alignment,
|
||||
context_alignment: Alignment,
|
||||
func: *const fn (*Io.Group, context: *const anyopaque) void,
|
||||
) Allocator.Error!*GroupClosure {
|
||||
const max_context_misalignment = context_alignment.toByteUnits() -| @alignOf(GroupClosure);
|
||||
@ -678,7 +679,7 @@ fn groupAsync(
|
||||
userdata: ?*anyopaque,
|
||||
group: *Io.Group,
|
||||
context: []const u8,
|
||||
context_alignment: std.mem.Alignment,
|
||||
context_alignment: Alignment,
|
||||
start: *const fn (*Io.Group, context: *const anyopaque) void,
|
||||
) void {
|
||||
if (builtin.single_threaded) return start(group, context.ptr);
|
||||
@ -794,7 +795,7 @@ fn await(
|
||||
userdata: ?*anyopaque,
|
||||
any_future: *Io.AnyFuture,
|
||||
result: []u8,
|
||||
result_alignment: std.mem.Alignment,
|
||||
result_alignment: Alignment,
|
||||
) void {
|
||||
_ = result_alignment;
|
||||
const t: *Threaded = @ptrCast(@alignCast(userdata));
|
||||
@ -806,7 +807,7 @@ fn cancel(
|
||||
userdata: ?*anyopaque,
|
||||
any_future: *Io.AnyFuture,
|
||||
result: []u8,
|
||||
result_alignment: std.mem.Alignment,
|
||||
result_alignment: Alignment,
|
||||
) void {
|
||||
_ = result_alignment;
|
||||
const t: *Threaded = @ptrCast(@alignCast(userdata));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user