As far as I can tell spawn returns a thread handle but I don’t understand the error.
This starts the thread
pub fn reader_start() std.Thread.SpawnError!std.Thread.Handle {
//pub fn reader_start() !void {
var handle = try std.Thread.spawn(.{}, reader_thrd, .{});
//_ = handle;
return handle;
}
This calls the function
//try reader.reader_start();
var handle: std.Thread.Handle = reader.reader_start() catch |err| {
std.debug.print(“Spawn failed: {}\n”, .{err});
};
_ = handle;
Errors
src\main.zig:77:71: error: expected type ‘*anyopaque’, found ‘void’
var handle: std.Thread.Handle = reader.reader_start() catch |err| {
src\net\udp_reader.zig:49:12: error: expected type ‘error{LockedMemoryLimitExceeded,OutOfMemory,SystemResources,ThreadQuotaExceeded,Unexpected}!*anyopaque’, found ‘Thread’
return handle;
I think I just don’t understand the return type or the error handling. If I return !void it all works.
Bob