Class: CLI::UI::StdoutRouter::Capture::BlockingInput
- Inherits:
-
Object
- Object
- CLI::UI::StdoutRouter::Capture::BlockingInput
- Defined in:
- lib/cli/ui/stdout_router.rb
Constant Summary collapse
- READING_METHODS =
[ :each, :each_byte, :each_char, :each_codepoint, :each_line, :getbyte, :getc, :getch, :gets, :read, :read_nonblock, :readbyte, :readchar, :readline, :readlines, :readpartial, ]
- NON_READING_METHODS =
IO.instance_methods(false) - READING_METHODS
Instance Method Summary collapse
-
#initialize(stream) ⇒ BlockingInput
constructor
: (IO stream) -> void.
-
#synchronize(&block) ⇒ Object
: [T] { -> T } -> T.
Constructor Details
#initialize(stream) ⇒ BlockingInput
: (IO stream) -> void
252 253 254 255 |
# File 'lib/cli/ui/stdout_router.rb', line 252 def initialize(stream) @stream = stream @m = CLI::UI::ReentrantMutex.new end |
Instance Method Details
#synchronize(&block) ⇒ Object
: [T] { -> T } -> T
258 259 260 261 262 263 264 265 266 |
# File 'lib/cli/ui/stdout_router.rb', line 258 def synchronize(&block) @m.synchronize do previous_allowed_to_read = Thread.current[:cliui_allowed_to_read] Thread.current[:cliui_allowed_to_read] = true block.call ensure Thread.current[:cliui_allowed_to_read] = previous_allowed_to_read end end |