diff --git a/src/libuv/Cond.zig b/src/libuv/Cond.zig index 269a24ebc..689863397 100644 --- a/src/libuv/Cond.zig +++ b/src/libuv/Cond.zig @@ -6,6 +6,7 @@ const Allocator = std.mem.Allocator; const testing = std.testing; const c = @import("c.zig"); const errors = @import("error.zig"); +const Mutex = @import("Mutex.zig"); cond: *c.uv_cond_t, @@ -29,8 +30,12 @@ pub fn broadcast(self: Cond) void { c.uv_cond_broadcast(self.cond); } -pub fn wait(self: Cond) void { - c.uv_cond_wait(self.cond); +pub fn wait(self: Cond, mutex: Mutex) void { + c.uv_cond_wait(self.cond, mutex.mutex); +} + +pub fn timedwait(self: Cond, mutex: Mutex, timeout: u64) c_int { + return c.uv_cond_timedwait(self.cond, mutex.mutex, timeout); } test { diff --git a/src/libuv/Loop.zig b/src/libuv/Loop.zig index 0bfa15c3c..ea07099b3 100644 --- a/src/libuv/Loop.zig +++ b/src/libuv/Loop.zig @@ -79,6 +79,17 @@ pub fn now(self: Loop) u64 { return c.uv_now(self.loop); } +/// Update the event loop’s concept of “now”. Libuv caches the current time at +/// the start of the event loop tick in order to reduce the number of time-related +/// system calls. +/// +/// You won’t normally need to call this function unless you have callbacks +/// that block the event loop for longer periods of time, where “longer” is +/// somewhat subjective but probably on the order of a millisecond or more. +pub fn updateTime(self: Loop) void { + return c.uv_update_time(self.loop); +} + /// Sets loop->data to data. pub fn setData(self: Loop, pointer: ?*anyopaque) void { c.uv_loop_set_data(self.loop, pointer);