Updating time duration functions.

This commit is contained in:
Christoffer Lerno
2023-09-05 10:57:50 +02:00
parent 53598b8c40
commit ffb7935e12
10 changed files with 80 additions and 60 deletions

View File

@@ -54,6 +54,11 @@ struct Poll
PollEvents revents;
}
fn ulong! poll_ms(Poll[] polls, long timeout_ms)
{
return poll(polls, time::ms(timeout_ms)) @inline;
}
/**
* @param [inout] polls
* @param timeout "duration to poll."

View File

@@ -14,3 +14,15 @@ fn UdpSocket! connect_to(AddrInfo* ai, SocketOption... options)
{
return (UdpSocket)net::connect_from_addrinfo(ai, options);
}
fn UdpSocket! connect_async(String host, uint port, SocketOption... options, IpProtocol protocol = UNSPECIFIED)
{
AddrInfo* ai = net::addrinfo(host, port, protocol.ai_family, os::SOCK_DGRAM)!;
defer os::freeaddrinfo(ai);
return connect_async_to(ai, ...options);
}
fn UdpSocket! connect_async_to(AddrInfo* ai, SocketOption... options)
{
return (UdpSocket)net::connect_async_from_addrinfo(ai, options);
}