Efl.Io.Buffered_Stream (class)

Description

A wrapper object offering easy to use buffered streams over existing I/O class.

The buffered stream encapsulates an actual Efl.Io.Reader or Efl.Io.Writer, an input Efl.Io.Queue and an output Efl.Io.Queue. These are linked using a input and a output Efl.Io.Copier.

The idea is that unlike the traditional Efl.Io.Writer which will attempt to write directly and thus may take less data than requested, this one will keep the pending data in its own buffer, feeding to the actual output when Efl.Io.Writer can write. That makes its operation much simpler as Efl.Io.Writer.write will always take the full data -- allows "write and forget", if unlimited (see Efl.Io.Buffered_Stream.max_queue_size_output). When finished writing data Efl.Io.Buffered_Stream.eos_mark then waits for the "write.finished" event to know all data has been sent.

Reading is also much simpler since incoming data is kept in an Efl.Io.Queue, thus its size can be queried with Efl.Io.Buffered_Stream.pending_read and read with Efl.Io.Reader.read or peeked with Efl.Io.Buffered_Stream.slice, then discarded with Efl.Io.Buffered_Stream.discard or Efl.Io.Buffered_Stream.clear.

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 Efl.Io.Buffered_Stream.slice and then Efl.Io.Buffered_Stream.discard.

The actual I/O is set with the constructor method Efl.Io.Buffered_Stream.inner_io.set and can be retrieved with Efl.Io.Buffered_Stream.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.

Inheritance

Efl.Loop_Consumer (class)Efl.Object (class)

Full hierarchy

Members

can_read (get, set) protected set [Overridden from Efl.Io.Reader]

If true will notify Efl.Io.Reader.read can be called without blocking or failing.
Eina_Bool efl_io_reader_can_read_get(const Eo *obj);
void efl_io_reader_can_read_set(Eo *obj, Eina_Bool can_read);


can_write (get, set) protected set [Overridden from Efl.Io.Writer]

If true will notify Efl.Io.Writer.write can be called without blocking or failing.
Eina_Bool efl_io_writer_can_write_get(const Eo *obj);
void efl_io_writer_can_write_set(Eo *obj, Eina_Bool can_write);


clear

Clears the incoming queue. Same as reading all data.
void efl_io_buffered_stream_clear(Eo *obj);


close [Overridden from Efl.Io.Closer]

Closes the Input/Output object.
Eina_Error efl_io_closer_close(Eo *obj);


close_on_exec (get, set) [Overridden from Efl.Io.Closer]

If true will automatically close resources on exec() calls.
Eina_Bool efl_io_closer_close_on_exec_get(const Eo *obj);
Eina_Bool efl_io_closer_close_on_exec_set(Eo *obj, Eina_Bool close_on_exec);


close_on_invalidate (get, set) [Overridden from Efl.Io.Closer]

If true will automatically close() on object invalidate.
Eina_Bool efl_io_closer_close_on_invalidate_get(const Eo *obj);
void efl_io_closer_close_on_invalidate_set(Eo *obj, Eina_Bool close_on_invalidate);


closed (get) [Overridden from Efl.Io.Closer]

Eina_Bool efl_io_closer_closed_get(const Eo *obj);


discard

Discards the given number of bytes.
void efl_io_buffered_stream_discard(Eo *obj, size_t amount);


eos (get, set) protected set [Overridden from Efl.Io.Reader]

If true will notify end of stream.
Eina_Bool efl_io_reader_eos_get(const Eo *obj);
void efl_io_reader_eos_set(Eo *obj, Eina_Bool is_eos);


eos_mark

Marks the end-of-stream. Signals nothing else will be written.
void efl_io_buffered_stream_eos_mark(Eo *obj);


finalize [Overridden from Efl.Object]

Implement this method to finish the initialization of your object after all (if any) user-provided configuration methods have been executed.
Efl_Object *efl_finalize(Eo *obj);


flush

Forces writing all pending data to destination.
Eina_Bool efl_io_buffered_stream_flush(Eo *obj, Eina_Bool may_block, Eina_Bool ignore_line_delimiter);


inner_io (get, set)

The inner I/O this wrapper operates on.
Efl_Object *efl_io_buffered_stream_inner_io_get(const Eo *obj);
void efl_io_buffered_stream_inner_io_set(Eo *obj, Efl_Object *io);


invalidate [Overridden from Efl.Object]

Implement this method to perform special actions when your object loses its parent, if you need to.
void efl_invalidate(Eo *obj);


line_delimiter (get, set)

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 Efl.Io.Buffered_Stream.max_queue_size_input has been reached.
const Eina_Slice efl_io_buffered_stream_line_delimiter_get(const Eo *obj);
void efl_io_buffered_stream_line_delimiter_set(Eo *obj, const Eina_Slice slice);


max_queue_size_input (get, set)

Limits how big the input queue can grow, in bytes.
size_t efl_io_buffered_stream_max_queue_size_input_get(const Eo *obj);
void efl_io_buffered_stream_max_queue_size_input_set(Eo *obj, size_t max_queue_size_input);


max_queue_size_output (get, set)

Limits how big the output queue can grow in bytes.
size_t efl_io_buffered_stream_max_queue_size_output_get(const Eo *obj);
void efl_io_buffered_stream_max_queue_size_output_set(Eo *obj, size_t max_queue_size_output);


pending_read (get)

size_t efl_io_buffered_stream_pending_read_get(const Eo *obj);


pending_write (get)

size_t efl_io_buffered_stream_pending_write_get(const Eo *obj);


progress (get)

void efl_io_buffered_stream_progress_get(const Eo *obj, size_t *read_bytes, size_t *written_bytes);


read [Overridden from Efl.Io.Reader]

Reads data into a pre-allocated buffer.
Eina_Error efl_io_reader_read(Eo *obj, Eina_Rw_Slice rw_slice);


read_chunk_size (get, set)

Reads chunk size property, in bytes.
size_t efl_io_buffered_stream_read_chunk_size_get(const Eo *obj);
void efl_io_buffered_stream_read_chunk_size_set(Eo *obj, size_t size);


slice (get)

Eina_Slice efl_io_buffered_stream_slice_get(const Eo *obj);


timeout_inactivity (get, set)

Error as ETIMEDOUT if it becomes inactive for some time.
double efl_io_buffered_stream_timeout_inactivity_get(const Eo *obj);
void efl_io_buffered_stream_timeout_inactivity_set(Eo *obj, double seconds);


write [Overridden from Efl.Io.Writer]

Writes data from a pre-populated buffer.
Eina_Error efl_io_writer_write(Eo *obj, Eina_Slice slice, Eina_Slice *remaining);


Inherited

Efl.Loop_Consumer
future_rejected Creates a new future that is already rejected to a specified error using the Efl.Loop_Consumer.loop.get.
future_resolved Creates a new future that is already resolved to a value.
loop (get)
parent (get, set) The parent of an object.
promise_new Create a new promise with the scheduler coming from the loop provided by this object.
Efl.Object
allow_parent_unref (get, set) Allow an object to be deleted by unref even if it has a parent.
children_iterator_new Get an iterator on all children.
comment (get, set) A human readable comment for the object.
composite_attach Make an object a composite object of another.
composite_detach Detach a composite object from another object.
composite_part_is Check if an object is part of a composite object.
constructor Implement this method to provide optional initialization code for your object.
debug_name_override Build a read-only name for this object used for debugging.
destructor Implement this method to provide deinitialization code for your object if you need it.
event_callback_forwarder_del Remove an event callback forwarder for a specified event and object.
event_callback_forwarder_priority_add Add an event callback forwarder that will make this object emit an event whenever another object (source) emits it. The event is said to be forwarded from source to this object.
event_callback_stop Stop the current callback call.
event_freeze Freeze events of this object.
event_freeze_count (get)
static event_global_freeze Globally freeze events for ALL EFL OBJECTS.
static event_global_freeze_count (get)
static event_global_thaw Globally thaw events for ALL EFL OBJECTS.
event_thaw Thaw events of object.
finalized (get)
invalidated (get)
invalidating (get)
name (get, set) The name of the object.
name_find Find a child object with the given name and return it.
provider_find Searches upwards in the object tree for a provider which knows the given class/interface.
provider_register Will register a manager of a specific class to be answered by Efl.Object.provider_find.
provider_unregister Will unregister a manager of a specific class that was previously registered and answered by Efl.Object.provider_find.

Events

error

An error has occurred and I/O has stopped
EFL_IO_BUFFERED_STREAM_EVENT_ERROR(Eina_Error)


finished

Both read and write are finished.
EFL_IO_BUFFERED_STREAM_EVENT_FINISHED(void)


line

If Efl.Io.Buffered_Stream.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 Efl.Io.Buffered_Stream.slice.
EFL_IO_BUFFERED_STREAM_EVENT_LINE(const Eina_Slice *)


progress

EFL_IO_BUFFERED_STREAM_EVENT_PROGRESS(void)


read,finished

Same as Efl.Io.Reader "eos", for consistency.
EFL_IO_BUFFERED_STREAM_EVENT_READ_FINISHED(void)


slice,changed

The read-slice returned by Efl.Io.Buffered_Stream.slice may have changed.
EFL_IO_BUFFERED_STREAM_EVENT_SLICE_CHANGED(void)


write,finished

Efl.Io.Buffered_Stream.eos_mark was called and all available data was sent to destination
EFL_IO_BUFFERED_STREAM_EVENT_WRITE_FINISHED(void)


Inherited

Efl.Io.Closer
closed Notifies closed, when property is marked as true
Efl.Io.Reader
can_read,changed Notifies can_read property changed.
eos Notifies end of stream, when property is marked as true.
Efl.Io.Writer
can_write,changed Notifies can_write property changed.
Efl.Object
del Object is being deleted. See Efl.Object.destructor.
destruct Object has been fully destroyed. It can not be used beyond this point. This event should only serve to clean up any reference you keep to the object.
invalidate Object is being invalidated and losing its parent. See Efl.Object.invalidate.
noref Object has lost its last reference, only parent relationship is keeping it alive. Advanced usage.
ownership,shared Object has acquired a second reference. It has multiple owners now. Triggered whenever increasing the refcount from one to two, it will not trigger by further increasing the refcount beyond two.
ownership,unique Object has lost a reference and only one is left. It has just one owner now. Triggered whenever the refcount goes from two to one.