| ... | @@ -773,7 +773,7 @@ pub const Loop = struct { | ... | @@ -773,7 +773,7 @@ pub const Loop = struct { |
| 773 | self.delay_queue.waiters.insert(&entry); | 773 | self.delay_queue.waiters.insert(&entry); |
| 774 | | 774 | |
| 775 | // Speculatively wake up the timer thread when we add a new entry. | 775 | // Speculatively wake up the timer thread when we add a new entry. |
| 776 | // If the timer thread is sleeping on a longer entry, we need to | 776 | // If the timer thread is sleeping on a longer entry, we need to |
| 777 | // interrupt it so that our entry can be expired in time. | 777 | // interrupt it so that our entry can be expired in time. |
| 778 | self.delay_queue.event.set(); | 778 | self.delay_queue.event.set(); |
| 779 | } | 779 | } |
| ... | @@ -785,7 +785,7 @@ pub const Loop = struct { | ... | @@ -785,7 +785,7 @@ pub const Loop = struct { |
| 785 | thread: *std.Thread, | 785 | thread: *std.Thread, |
| 786 | event: std.AutoResetEvent, | 786 | event: std.AutoResetEvent, |
| 787 | is_running: bool, | 787 | is_running: bool, |
| 788 | | 788 | |
| 789 | /// Initialize the delay queue by spawning the timer thread | 789 | /// Initialize the delay queue by spawning the timer thread |
| 790 | /// and starting any timer resources. | 790 | /// and starting any timer resources. |
| 791 | fn init(self: *DelayQueue) !void { | 791 | fn init(self: *DelayQueue) !void { |
| ... | @@ -800,7 +800,7 @@ pub const Loop = struct { | ... | @@ -800,7 +800,7 @@ pub const Loop = struct { |
| 800 | }; | 800 | }; |
| 801 | } | 801 | } |
| 802 | | 802 | |
| 803 | /// Entry point for the timer thread | 803 | /// Entry point for the timer thread |
| 804 | /// which waits for timer entries to expire and reschedules them. | 804 | /// which waits for timer entries to expire and reschedules them. |
| 805 | fn run(self: *DelayQueue) void { | 805 | fn run(self: *DelayQueue) void { |
| 806 | const loop = @fieldParentPtr(Loop, "delay_queue", self); | 806 | const loop = @fieldParentPtr(Loop, "delay_queue", self); |
| ... | @@ -848,12 +848,12 @@ pub const Loop = struct { | ... | @@ -848,12 +848,12 @@ pub const Loop = struct { |
| 848 | const entry = self.peekExpiringEntry() orelse return null; | 848 | const entry = self.peekExpiringEntry() orelse return null; |
| 849 | if (entry.expires > now) | 849 | if (entry.expires > now) |
| 850 | return null; | 850 | return null; |
| 851 | | 851 | |
| 852 | assert(self.entries.remove(&entry.node)); | 852 | assert(self.entries.remove(&entry.node)); |
| 853 | return entry; | 853 | return entry; |
| 854 | } | 854 | } |
| 855 | | 855 | |
| 856 | /// Returns an estimate for the amount of time | 856 | /// Returns an estimate for the amount of time |
| 857 | /// to wait until the next waiting entry expires. | 857 | /// to wait until the next waiting entry expires. |
| 858 | fn nextExpire(self: *Waiters) ?u64 { | 858 | fn nextExpire(self: *Waiters) ?u64 { |
| 859 | const entry = self.peekExpiringEntry() orelse return null; | 859 | const entry = self.peekExpiringEntry() orelse return null; |