@@ -23,6 +23,8 @@ const MemoryPool = std.heap.MemoryPool;
2323const log = @import ("../log.zig" );
2424pub const IO = @import ("tigerbeetle-io" ).IO ;
2525
26+ const RUN_DURATION = 10 * std .time .ns_per_ms ;
27+
2628// SingleThreaded I/O Loop based on Tigerbeetle io_uring loop.
2729// On Linux it's using io_uring.
2830// On MacOS and Windows it's using kqueue/IOCP with a ring design.
@@ -82,7 +84,7 @@ pub const Loop = struct {
8284 // run tail events. We do run the tail events to ensure all the
8385 // contexts are correcly free.
8486 while (self .pending_network_count != 0 or self .pending_timeout_count != 0 ) {
85- self .io .run_for_ns (std . time . ns_per_ms * 10 ) catch | err | {
87+ self .io .run_for_ns (RUN_DURATION ) catch | err | {
8688 log .err (.loop , "deinit" , .{ .err = err });
8789 break ;
8890 };
@@ -102,12 +104,12 @@ pub const Loop = struct {
102104 // Stops when there is no more I/O events registered on the loop.
103105 // Note that I/O events callbacks might register more I/O events
104106 // on the go when they are executed (ie. nested I/O events).
105- pub fn run (self : * Self , wait_time : usize ) ! void {
107+ pub fn run (self : * Self , wait_ns : usize ) ! void {
106108 // stop repeating / interval timeouts from re-registering
107109 self .stopping = true ;
108110 defer self .stopping = false ;
109111
110- const max_iterations = wait_time / (std . time . ns_per_ms * 10 );
112+ const max_iterations = wait_ns / (RUN_DURATION );
111113 for (0.. max_iterations ) | _ | {
112114 if (self .pending_network_count == 0 and self .pending_timeout_count == 0 ) {
113115 break ;
0 commit comments