Skip to content

add interruptible stdin hint to docs - #377

Merged
adamw merged 2 commits into
softwaremill:masterfrom
lbialy:add-interruptible-stdin-to-docs
Nov 10, 2025
Merged

add interruptible stdin hint to docs#377
adamw merged 2 commits into
softwaremill:masterfrom
lbialy:add-interruptible-stdin-to-docs

Conversation

@lbialy

@lbialy lbialy commented Nov 2, 2025

Copy link
Copy Markdown
Contributor

No description provided.

impossible to interrupt such operations directly. This pattern extends to other similar blocking operations that behave
like stdin.

The solution is to delegate the blocking operation to a separate thread and use a [channel](../streaming/channels.md)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome that you remembered - thanks! :) Maybe it would also be good to mention why the thread needs to be manually created, not Ox-managed (that is, not created through fork)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Comment thread doc/other/best-practices.md Outdated
Note that for better stdin performance, you can use `Channel.buffered` instead of a rendezvous channel, or even use
`java.lang.System.in` directly and proxy raw data through the channel. Keep in mind that this solution leaks a thread
that will remain blocked on stdin for the lifetime of the application. It's possible to avoid this trade-off by using
libraries that employ JNI/JNA to access stdin, such as JLine 3, which can use raw mode with non-blocking or

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe a link on how to do that?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

meaning how to use jline3 or how it uses raw mode with O_NONBLOCKING or VTIME=1?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a link to JLine 3 - maybe an appropriate docs page, or anything that would help people use it in a project

@lbialy

lbialy commented Nov 5, 2025

Copy link
Copy Markdown
Contributor Author

@adamw done

@adamw

adamw commented Nov 10, 2025

Copy link
Copy Markdown
Member

Thanks! :)

@adamw
adamw merged commit fd7aa9c into softwaremill:master Nov 10, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants