Class: EventCore::PipeSource
Overview
A source that triggers when data is ready to be read from an internal pipe. Send data to the pipe with the (blocking) write() method.
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Source
#event_factory, #notify_trigger, #ready!, #ready?, #timeout, #trigger
Constructor Details
Returns a new instance of PipeSource.
125
126
127
128
129
130
131
|
# File 'lib/event_core.rb', line 125
def initialize
super()
@rio, @wio = IO.pipe
@rio.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC | Fcntl::O_NONBLOCK)
@buffer_size = 4096
end
|
Instance Attribute Details
#rio ⇒ Object
Returns the value of attribute rio.
123
124
125
|
# File 'lib/event_core.rb', line 123
def rio
@rio
end
|
#wio ⇒ Object
Returns the value of attribute wio.
123
124
125
|
# File 'lib/event_core.rb', line 123
def wio
@wio
end
|
Instance Method Details
#close! ⇒ Object
153
154
155
156
157
|
# File 'lib/event_core.rb', line 153
def close!
super
@rio.close unless @rio.closed?
@wio.close unless @wio.closed?
end
|
#closed? ⇒ Boolean
149
150
151
|
# File 'lib/event_core.rb', line 149
def closed?
@rio.closed?
end
|
#consume_event_data! ⇒ Object
141
142
143
144
145
146
147
|
# File 'lib/event_core.rb', line 141
def consume_event_data!
begin
@rio.read_nonblock(@buffer_size)
rescue EOFError
nil
end
end
|
#select_io ⇒ Object
133
134
135
|
# File 'lib/event_core.rb', line 133
def select_io
@rio
end
|
#select_type ⇒ Object
137
138
139
|
# File 'lib/event_core.rb', line 137
def select_type
:read
end
|
#write(buf) ⇒ Object
159
160
161
|
# File 'lib/event_core.rb', line 159
def write(buf)
@wio.write(buf)
end
|