#error: expected type 'void', found 'error{SystemResources,Unexpected,OutOfMemory,ThreadQuotaExceeded

1 messages · Page 1 of 1 (latest)

twin ferry
#

I'm trying to multithread two functions but when I try to build the code I get the mentioned errors, the code I have is

    InitializeThreads();
}

fn InitializeThreads() void {
    const physicsThread = try std.Thread.spawn(.{}, PhysicsUpdate, null);
    _ = physicsThread;
    const inputThread = try std.Thread.spawn(.{}, InputUpdate(), null);
    _ = inputThread;
}

fn PostUpdate() void {}
fn PhysicsUpdate() void {}
stoic river
#

you're using try instead of a function that doesn't return an error

#

try is basically syntax sugar for catch |err| return err;, where the error is return, if there is one.

#

InitializeThreads needs to return !void, to indicate a inferred error set unioned with void.
and then in Run you'll need to do the same thing, and call it with try InitializeThreads()