File: nonblock.rb

package info (click to toggle)
ruby-io-event 1.14.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 400 kB
  • sloc: ansic: 3,709; ruby: 736; makefile: 4
file content (21 lines) | stat: -rw-r--r-- 428 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# frozen_string_literal: true

# Released under the MIT License.
# Copyright, 2022-2024, by Samuel Williams.

require "io/nonblock"

module IO::Event
	module Selector
		# Execute the given block in non-blocking mode.
		#
		# @parameter io [IO] The IO object to operate on.
		# @yields {...} The block to execute.
		def self.nonblock(io, &block)
			io.nonblock(&block)
		rescue Errno::EBADF
			# Windows.
			yield
		end
	end
end