| ... | ... | @@ -8,7 +8,7 @@ |
| 8 | 8 | //! to wake up. Spurious wakeups are possible. |
| 9 | 9 | //! This API supports static initialization and does not require deinitialization. |
| 10 | 10 | |
| 11 | | impl: Impl, |
| 11 | impl: Impl = .{}, |
| 12 | 12 | |
| 13 | 13 | const std = @import("../std.zig"); |
| 14 | 14 | const Condition = @This(); |
| ... | ... | @@ -17,6 +17,18 @@ const linux = std.os.linux; |
| 17 | 17 | const Mutex = std.Thread.Mutex; |
| 18 | 18 | const assert = std.debug.assert; |
| 19 | 19 | |
| 20 | pub fn wait(cond: *Condition, mutex: *Mutex) void { |
| 21 | cond.impl.wait(mutex); |
| 22 | } |
| 23 | |
| 24 | pub fn signal(cond: *Condition) void { |
| 25 | cond.impl.signal(); |
| 26 | } |
| 27 | |
| 28 | pub fn broadcast(cond: *Condition) void { |
| 29 | cond.impl.broadcast(); |
| 30 | } |
| 31 | |
| 20 | 32 | const Impl = if (std.builtin.single_threaded) |
| 21 | 33 | SingleThreadedCondition |
| 22 | 34 | else if (std.Target.current.os.tag == .windows) |
| ... | ... | @@ -62,7 +74,7 @@ pub const PthreadCondition = struct { |
| 62 | 74 | cond: std.c.pthread_cond_t = .{}, |
| 63 | 75 | |
| 64 | 76 | pub fn wait(cond: *PthreadCondition, mutex: *Mutex) void { |
| 65 | | const rc = std.c.pthread_cond_wait(&cond.cond, &mutex.mutex); |
| 77 | const rc = std.c.pthread_cond_wait(&cond.cond, &mutex.impl.pthread_mutex); |
| 66 | 78 | assert(rc == 0); |
| 67 | 79 | } |
| 68 | 80 | |