2019-01-18 05:22:23 -08:00
class Efl.Io.Buffered_Stream extends Efl.Loop_Consumer implements Efl.Io.Reader, Efl.Io.Writer, Efl.Io.Closer {
2017-12-20 01:41:41 -08:00
[[A wrapper object offering easy to use buffered streams over existing I/O class.
2016-11-24 19:27:33 -08:00
The buffered stream encapsulates an actual @Efl.Io.Reader or
2017-12-20 01:41:41 -08:00
@Efl.Io.Writer, an input @Efl.Io.Queue and an output @Efl.Io.Queue.
These are linked using a input and a output
2016-11-24 19:27:33 -08:00
@Efl.Io.Copier.
2017-12-20 01:41:41 -08:00
The idea is that unlike the traditional @Efl.Io.Writer which will
2016-11-24 19:27:33 -08:00
attempt to write directly and thus may take less data than
requested, this one will keep the pending data in its own
2017-12-20 01:41:41 -08:00
buffer, feeding to the actual output when
@Efl.Io.Writer can write. That makes its operation much simpler
2016-11-24 19:27:33 -08:00
as @Efl.Io.Writer.write will always take the full data -- allows
"write and forget", if unlimited (see
2017-12-20 01:41:41 -08:00
@.max_queue_size_output). When finished writing data
@.eos_mark then waits for the "write.finished" event to know all data
has been sent.
2016-11-24 19:27:33 -08:00
Reading is also much simpler since incoming data is kept in an
@Efl.Io.Queue, thus its size can be queried with @.pending_read
2016-12-19 08:46:37 -08:00
and read with @Efl.Io.Reader.read or peeked with @.slice,
2016-11-24 19:27:33 -08:00
then discarded with @.discard or @.clear.
2017-12-20 01:41:41 -08:00
When waiting for a complete message, just peek at its
contents, if not complete do nothing and wait. If complete then
use either @Efl.Io.Reader.read to get a copy or manipulate a
read-only reference from @.slice and then @.discard.
2016-11-24 19:27:33 -08:00
The actual I/O is set with the constructor method @.inner_io.set
and can be retrieved with @.inner_io.get, which should be used
with care -- calling @Efl.Io.Reader.read and
@Efl.Io.Writer.write on it may produce unexpected results.
@since 1.19
]]
methods {
@property inner_io {
[[The inner I/O this wrapper operates on.]]
get {
2017-12-20 01:41:41 -08:00
[[The internal input/output used for actual operations. Use with care!]]
2016-11-24 19:27:33 -08:00
}
set {
[[Constructor-only property to set the inner_io.]]
}
values {
io: Efl.Object; [[The input (@Efl.Io.Reader) or output (@Efl.Io.Writer) instance]]
}
}
@property max_queue_size_input {
docs: Fix typos and some wrong expressions in Ecore, Ecore_Audio, Ecore_Cocoa, Ecore_Con, and Ector API reference doxygen.
Summary: I had fixed some typos and wrong expressions, such as capital letters, $simbols in .eo and singulars in Ecore, Ecore_Audio, Ecore_Cocoa, Ecore_Con, and Ector API reference doxygen.
Test Plan: Doxygen Revision
Reviewers: Jaehyun_Cho, stefan, jpeg, cedric, raster
Reviewed By: Jaehyun_Cho
Differential Revision: https://phab.enlightenment.org/D4943
2017-06-06 21:01:13 -07:00
[[Limits how big the input queue can grow, in bytes.
2016-11-24 19:27:33 -08:00
If limited and @.line_delimiter is set, "line" events
2017-12-20 01:41:41 -08:00
may be emitted with partial contents without the
2016-11-24 19:27:33 -08:00
trailing delimiter.
]]
get { }
set {
[[Constructor-only property to set buffer limit. 0 is unlimited]]
}
values {
2017-12-20 01:41:41 -08:00
max_queue_size_input: size; [[Defines a maximum buffer size for incoming data or 0 to allow an unlimited amount of bytes]]
2016-11-24 19:27:33 -08:00
}
}
@property max_queue_size_output {
2017-12-20 01:41:41 -08:00
[[Limits how big the output queue can grow in bytes.
2016-11-24 19:27:33 -08:00
2017-12-20 01:41:41 -08:00
If limited @Efl.Io.Writer.write will take less data than requested.
2016-11-24 19:27:33 -08:00
]]
get { }
set {
[[Constructor-only property to set buffer limit. 0 is unlimited]]
}
values {
2017-12-20 01:41:41 -08:00
max_queue_size_output: size; [[Defines a maximum buffer size for output data, or 0 to allow unlimited amount of bytes. If limited, @Efl.Io.Writer.write will take less data than requested.]]
2016-11-24 19:27:33 -08:00
}
}
@property line_delimiter {
2017-12-20 01:41:41 -08:00
[[If set incoming data will be checked for the delimiter and "line" events. The line may include the delimiter, unless it's end-of-stream in @.max_queue_size_input has been reached.]]
2016-11-24 19:27:33 -08:00
get { }
set {
2017-12-20 01:41:41 -08:00
[[Changes line delimiter to use. If empty no delimiter is to be used]]
2016-11-24 19:27:33 -08:00
}
values {
2017-08-10 03:53:14 -07:00
slice: const(Eina.Slice); [[The contents may contain \0 and will be copied]]
2016-11-24 19:27:33 -08:00
}
}
2016-12-11 07:19:46 -08:00
@property timeout_inactivity {
2016-11-24 19:27:33 -08:00
[[Error as ETIMEDOUT if it becomes inactive for some time.
If no activity, that is no read or write in the given
amount of seconds, then the object will emit "error"
event with ETIMEDOUT value.
This is specified in seconds and is only active for
greater-than zero. Defaults to inactive.
]]
values {
2017-12-20 01:41:41 -08:00
seconds: double; [[Number of inactive seconds to timeout this object. If zero or less it will be disabled.]]
2016-11-24 19:27:33 -08:00
}
}
@property read_chunk_size {
docs: Fix typos and some wrong expressions in Ecore, Ecore_Audio, Ecore_Cocoa, Ecore_Con, and Ector API reference doxygen.
Summary: I had fixed some typos and wrong expressions, such as capital letters, $simbols in .eo and singulars in Ecore, Ecore_Audio, Ecore_Cocoa, Ecore_Con, and Ector API reference doxygen.
Test Plan: Doxygen Revision
Reviewers: Jaehyun_Cho, stefan, jpeg, cedric, raster
Reviewed By: Jaehyun_Cho
Differential Revision: https://phab.enlightenment.org/D4943
2017-06-06 21:01:13 -07:00
[[Reads chunk size property, in bytes.
2016-11-24 19:27:33 -08:00
When reading the @.inner_io for data to be placed in
2017-12-20 01:41:41 -08:00
input queue use this as chunk size.
2016-11-24 19:27:33 -08:00
Setting this value large enough may reduce number of
@Efl.Io.Reader.read, improving performance at the expense
of more memory consumption.
2017-12-20 01:41:41 -08:00
This value is limited by @.max_queue_size_input if it's set.
2016-11-24 19:27:33 -08:00
By default it's 4096.
]]
get {
}
set {
docs: Fix typos and some wrong expressions in Ecore, Ecore_Audio, Ecore_Cocoa, Ecore_Con, and Ector API reference doxygen.
Summary: I had fixed some typos and wrong expressions, such as capital letters, $simbols in .eo and singulars in Ecore, Ecore_Audio, Ecore_Cocoa, Ecore_Con, and Ector API reference doxygen.
Test Plan: Doxygen Revision
Reviewers: Jaehyun_Cho, stefan, jpeg, cedric, raster
Reviewed By: Jaehyun_Cho
Differential Revision: https://phab.enlightenment.org/D4943
2017-06-06 21:01:13 -07:00
[[Sets chunk size for each basic @Efl.Io.Reader.read operation.]]
2016-11-24 19:27:33 -08:00
}
values {
size: size; [[This is the chunk size to use for read operations]]
}
}
@property pending_write {
[[How many bytes are pending write to @.inner_io]]
get { }
values {
usage: size; [[Bytes available to write]]
}
}
@property pending_read {
[[How many bytes are pending (available) for read]]
get { }
values {
usage: size; [[Bytes available to read]]
}
}
2016-12-07 10:55:42 -08:00
@property progress {
[[How many bytes were written and read.]]
get { }
values {
read_bytes: size; [[Bytes that were read until now]]
written_bytes: size; [[Bytes that were written until now]]
}
}
2016-12-19 08:46:37 -08:00
@property slice {
docs: Fix typos and some wrong expressions in Ecore, Ecore_Audio, Ecore_Cocoa, Ecore_Con, and Ector API reference doxygen.
Summary: I had fixed some typos and wrong expressions, such as capital letters, $simbols in .eo and singulars in Ecore, Ecore_Audio, Ecore_Cocoa, Ecore_Con, and Ector API reference doxygen.
Test Plan: Doxygen Revision
Reviewers: Jaehyun_Cho, stefan, jpeg, cedric, raster
Reviewed By: Jaehyun_Cho
Differential Revision: https://phab.enlightenment.org/D4943
2017-06-06 21:01:13 -07:00
[[Gets a temporary access to input queue's internal read memory.
2016-11-24 19:27:33 -08:00
The memory pointed by slice may be changed by other
methods of this class. The event "slice,changed" will be
2017-12-20 01:41:41 -08:00
called in those circumstances.
2016-11-24 19:27:33 -08:00
]]
2016-12-19 08:46:37 -08:00
get { }
values {
slice: Eina.Slice; [[Slice of the current buffer, may be invalidated if @Efl.Io.Writer.write, @Efl.Io.Closer.close or @Efl.Io.Reader.read are called. It is the full slice available for reading.]]
2016-11-24 19:27:33 -08:00
}
}
discard {
docs: Fix typos and some wrong expressions in Ecore, Ecore_Audio, Ecore_Cocoa, Ecore_Con, and Ector API reference doxygen.
Summary: I had fixed some typos and wrong expressions, such as capital letters, $simbols in .eo and singulars in Ecore, Ecore_Audio, Ecore_Cocoa, Ecore_Con, and Ector API reference doxygen.
Test Plan: Doxygen Revision
Reviewers: Jaehyun_Cho, stefan, jpeg, cedric, raster
Reviewed By: Jaehyun_Cho
Differential Revision: https://phab.enlightenment.org/D4943
2017-06-06 21:01:13 -07:00
[[Discards the given number of bytes.
2016-11-24 19:27:33 -08:00
This has the same effect as reading and discarding the
given amount of bytes, without executing the actual
copy.
2017-12-20 01:41:41 -08:00
It's often paired with @.slice. If users read the
information from the slice, once they're done that
2016-11-24 19:27:33 -08:00
data must be discarded.
2017-12-20 01:41:41 -08:00
By way of example, some protocols provide messages with a
"size" header. In that case @.slice is used to peek into the
2016-11-24 19:27:33 -08:00
available memory to see if there is a "size" and if the
2017-12-20 01:41:41 -08:00
rest of the slice is the full payload. Here the
slice may be handled by a processing function. When
the function is complete, that amount of data must be
discarded -- by this function.
2016-11-24 19:27:33 -08:00
]]
params {
amount: size; [[Bytes to discard]]
}
}
clear {
docs: Fix typos and some wrong expressions in Ecore, Ecore_Audio, Ecore_Cocoa, Ecore_Con, and Ector API reference doxygen.
Summary: I had fixed some typos and wrong expressions, such as capital letters, $simbols in .eo and singulars in Ecore, Ecore_Audio, Ecore_Cocoa, Ecore_Con, and Ector API reference doxygen.
Test Plan: Doxygen Revision
Reviewers: Jaehyun_Cho, stefan, jpeg, cedric, raster
Reviewed By: Jaehyun_Cho
Differential Revision: https://phab.enlightenment.org/D4943
2017-06-06 21:01:13 -07:00
[[Clears the incoming queue. Same as reading all data.
2016-11-24 19:27:33 -08:00
2017-12-20 01:41:41 -08:00
This is equivalent to calling @.discard with @.pending_read
2016-11-24 19:27:33 -08:00
amount of bytes.
]]
}
eos_mark {
2017-12-20 01:41:41 -08:00
[[Marks the end-of-stream. Signals nothing else will be written.
2016-11-24 19:27:33 -08:00
2017-12-20 01:41:41 -08:00
This will forbid any further writes.
2016-11-24 19:27:33 -08:00
2017-12-20 01:41:41 -08:00
Unlike @Efl.Io.Closer.close this won't clear anything.
2016-11-24 19:27:33 -08:00
When all data is written, "write,finished" is emitted.
]]
}
flush {
[[Forces writing all pending data to destination.
It will return $true if @.pending_read drops to zero, $false
otherwise and more calls to flush must be made.
2017-12-20 01:41:41 -08:00
If the @.inner_io implements @Efl.Io.Closer and it
is closed or the wrapper itself's closed, this
function will do nothing and return $true.
2016-11-24 19:27:33 -08:00
2018-11-28 04:33:46 -08:00
Note: this function may block the main loop execution
2017-12-20 01:41:41 -08:00
until operations are complete! This is bad for usability as
the user interface or other operations may freeze. A better
approach is to operate asynchronously and wait for the
2016-11-24 19:27:33 -08:00
"write,finished" event.
]]
params {
may_block: bool; [[If $true, then @Efl.Io.Reader.can_read and @Efl.Io.Writer.can_write are not checked and the call may block.]]
docs: Fix typos and some wrong expressions in Ecore, Ecore_Audio, Ecore_Cocoa, Ecore_Con, and Ector API reference doxygen.
Summary: I had fixed some typos and wrong expressions, such as capital letters, $simbols in .eo and singulars in Ecore, Ecore_Audio, Ecore_Cocoa, Ecore_Con, and Ector API reference doxygen.
Test Plan: Doxygen Revision
Reviewers: Jaehyun_Cho, stefan, jpeg, cedric, raster
Reviewed By: Jaehyun_Cho
Differential Revision: https://phab.enlightenment.org/D4943
2017-06-06 21:01:13 -07:00
ignore_line_delimiter: bool; [[Forces flush ignoring line delimiters]]
2016-11-24 19:27:33 -08:00
}
return: bool(true); [[$true if all data was sent, $false otherwise]]
}
}
events {
efl: Add missing event types
Summary:
All events must have a type now, otherwise bindings don't know how to handle
the event_info field.
Most of the missing event types were actually "void" (no event_info present).
Some struct definitions had to be moved to eo instead of h files, so they
are available to bindings. Some have not, and are marked with FIXME.
Some namespaces have been fixed (like Efl_Event_Cb -> Efl.Event_Cb).
In general, there are hundreds of changed files, but mostly to add a type which
was not present before, so there's no harm done.
Also, A lot of FIXMEs have been added which should be, like, fixed.
For example, some events can send different types of event_info, which is
very inconvenient (and error prone).
Test Plan: make with c# bindings works, make check and make examples work too.
Reviewers: cedric, q66, lauromoura
Subscribers: zmike
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D6169
2018-05-11 08:20:40 -07:00
write,finished: void; [[@.eos_mark was called and all available data was sent to destination]]
read,finished: void; [[Same as @Efl.Io.Reader "eos", for consistency.]]
finished: void; [[Both read and write are finished.]]
2017-12-20 01:41:41 -08:00
error: Eina.Error; [[An error has occurred and I/O has stopped]]
efl: Add missing event types
Summary:
All events must have a type now, otherwise bindings don't know how to handle
the event_info field.
Most of the missing event types were actually "void" (no event_info present).
Some struct definitions had to be moved to eo instead of h files, so they
are available to bindings. Some have not, and are marked with FIXME.
Some namespaces have been fixed (like Efl_Event_Cb -> Efl.Event_Cb).
In general, there are hundreds of changed files, but mostly to add a type which
was not present before, so there's no harm done.
Also, A lot of FIXMEs have been added which should be, like, fixed.
For example, some events can send different types of event_info, which is
very inconvenient (and error prone).
Test Plan: make with c# bindings works, make check and make examples work too.
Reviewers: cedric, q66, lauromoura
Subscribers: zmike
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D6169
2018-05-11 08:20:40 -07:00
progress: void; [[Property @.progress changed]]
slice,changed: void; [[The read-slice returned by @.slice may have changed.]]
2017-12-20 01:41:41 -08:00
line: ptr(const(Eina.Slice)); [[If @.line_delimiter is set, will be emitted with current line. The memory is only valid during event callback dispatched and should not be modified. Note that the line slice may not be inside @.slice.]]
2016-11-24 19:27:33 -08:00
}
implements {
Efl.Object.finalize;
2018-04-09 16:56:36 -07:00
Efl.Object.invalidate;
2016-11-24 19:27:33 -08:00
Efl.Io.Closer.close;
2016-12-27 07:19:06 -08:00
Efl.Io.Closer.closed { get; }
2017-01-11 07:35:03 -08:00
Efl.Io.Closer.close_on_exec { get; set; }
2018-04-17 16:17:29 -07:00
Efl.Io.Closer.close_on_invalidate { get; set; }
2016-11-24 19:27:33 -08:00
Efl.Io.Reader.read;
2017-01-11 07:35:03 -08:00
Efl.Io.Reader.can_read { get; set; }
Efl.Io.Reader.eos { get; set; }
2016-11-24 19:27:33 -08:00
Efl.Io.Writer.write;
2017-01-11 07:35:03 -08:00
Efl.Io.Writer.can_write { get; set; }
2016-11-24 19:27:33 -08:00
}
}