@@ -17,6 +17,9 @@ defmodule Emily.Stream do
1717 * `with_stream/2` — install a stream for the current process for
1818 the duration of a function call, then restore the previous
1919 stream (or the default) on exit. Nesting is safe.
20+ * `close/1` — stop a stream's worker deterministically instead of
21+ waiting for garbage collection: queued ops are cancelled (their
22+ callers raise) and the OS thread is joined off the BEAM schedulers.
2023
2124 ## How it works
2225
@@ -28,6 +31,25 @@ defmodule Emily.Stream do
2831 refcounted and thread-safe for reads), but lazy tensors must be
2932 evaluated on the stream that created them.
3033
34+ ## Configuration
35+
36+ Two application-env keys tune worker behaviour (set them in your
37+ `config/config.exs`):
38+
39+ * `:worker_queue_limit` (default `8192`) — the maximum number of
40+ operations that may be queued on a single worker before further
41+ dispatch is rejected with a `RuntimeError`. Each op is awaited
42+ synchronously, so a process holds at most one queued item; this cap
43+ is reached only by many processes dispatching to one worker
44+ concurrently, and provides back-pressure against a runaway producer.
45+ * `:await_timeout` (default `:infinity`) — milliseconds to wait for a
46+ native result before raising. `:infinity` never times out; set a
47+ finite value to bound how long a caller can block on one operation.
48+
49+ ```elixir
50+ config :emily, worker_queue_limit: 8192, await_timeout: :infinity
51+ ```
52+
3153 ## Concurrent serving patterns
3254
3355 **Stream-per-process** (shared model, per-process queues):
0 commit comments