Skip to content

non-blocking console input #58

@chdh

Description

@chdh

Please implement non-blocking console input, e.g. ConsoleReader.readCharacterNoWait(). It would only require a minor change in NonBlockingInputStream and ConsoleReader.

I'm writing a console-mode communications tool, where I have to read from the console without blocking. I know that I could use a separate thread to do that.

I tried the following code:

ConsoleReader con = new ConsoleReader();
NonBlockingInputStream in = (NonBlockingInputStream)(con.getInput());
int key = in.read(1);

But: 1. i'ts not guaranteed that future versions of ConsoleReader.getInput() will return a NonBlockingInputStream and 2. it blocks 1ms if no keyboard input is ready.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions