async: refacto with comptime generation

This commit is contained in:
Pierre Tachoire
2024-01-30 16:59:00 +01:00
parent c200f60d7d
commit 2fa66f93fd
4 changed files with 90 additions and 97 deletions

View File

@@ -6,7 +6,9 @@ const AsyncRequest = @import("http.zig").Request;
pub const Loop = @import("jsruntime").Loop;
const url = "https://www.w3.org/";
const TCPClient = @import("tcp.zig").Client;
const url = "https://w3.org";
test "blocking mode fetch API" {
const alloc = std.testing.allocator;
@@ -69,10 +71,10 @@ test "non blocking mode API" {
var client = AsyncClient.init(alloc, &loop);
defer client.deinit();
var reqs: [10]AsyncRequest = undefined;
var reqs: [10]*AsyncRequest = undefined;
for (0..reqs.len) |i| {
reqs[i] = client.create(try std.Uri.parse(url));
try reqs[i].fetch();
reqs[i] = try client.create(try std.Uri.parse(url));
reqs[i].fetch();
}
for (0..reqs.len) |i| {