zig/lib/std/Io
Loris Cro 8eaebf5939 Io.Threaded PoC reimplementation
This is a reimplementation of Io.Threaded that fixes the issues
highlighted in the recent Zulip discussion. It's poorly tested but it
does successfully run to completion the litmust test example that I
offered in the discussion.

This implementation has the following key design decisions:

- `t.cpu_count` is used as the threadpool size.
- `t.concurrency_limit` is used as the maximum number of
  "burst, one-shot" threads that can be spawned by `io.concurrent` past
  `t.cpu_count`.
- `t.available_thread_count` is the number of threads in the pool that
  is not currently busy with work (the bookkeeping happens in the worker
  function).
- `t.one_shot_thread_count` is the number of active threads that were
  spawned by `io.concurrent` past `t.cpu_count`.

In this implementation:

- `io.async` first tries to decrement `t.available_thread_count`. If
  there are no threads available, it tries to spawn a new one if possible,
  otherwise it runs the task immediately.
- `io.concurrent` first tries to use a thread in the pool same as
  `io.async`, but on failure (no available threads and pool size limit
  reached) it tries to spawn a new one-shot thread. One shot threads
  run a different main function that just executes one task, decrements
  the number of active one shot threads, and then exits.

A relevant future improvement is to have one-shot threads stay on for a
few seconds (and potentially pick up a new task) to amortize spawning
costs.
2025-11-21 19:54:41 -08:00
..
net std.Io.net: disable listen on a unix socket, send bytes, receive bytes on Windows 2025-11-19 21:51:57 +01:00
Reader Fix Reader.Limited end of stream conditions 2025-10-08 17:24:38 -07:00
Threaded std.Io: fix calls on functions that return an array type 2025-11-11 01:11:51 +01:00
Dir.zig std.Io: add dirMakePath and dirMakeOpenPath 2025-10-29 06:20:50 -07:00
File.zig Elf2: load archives 2025-10-29 18:07:12 -04:00
IoUring.zig std.Io: adjust concurrent error set 2025-10-29 06:20:51 -07:00
Kqueue.zig std.Io: fix Group.wait unsoundness 2025-10-29 06:20:52 -07:00
net.zig Io.net: set receive{,Timeout} message to init 2025-11-06 17:44:28 -08:00
Reader.zig Fix param name in doc comment for std.Io.Reader.peek() 2025-11-08 00:34:41 -08:00
test.zig Io.Queue: fix empty and full states being indistinguishable. 2025-11-04 04:24:32 -05:00
Threaded.zig Io.Threaded PoC reimplementation 2025-11-21 19:54:41 -08:00
tty.zig std.Build: don't force all children to inherit color option 2025-11-14 21:50:24 +01:00
Writer.zig Merge pull request #25981 from mlugg/macos-fuzz-2 2025-11-20 17:48:35 +00:00