Skip to content
Snippets Groups Projects
Commit 4f84859d authored by Vladimir Davydov's avatar Vladimir Davydov Committed by Vladimir Davydov
Browse files

Introduce iostream wrapper for socket I/O

Reading/writing fd directly doesn't let us add any data processing
transparently to the users. To overcome this limitation, let's wrap fd
in struct iostream. The new struct exposes virtual read/write methods,
which should be defined by a concrete implementation. It also allows to
access the associated fd, which is needed to poll the stream via libev.
For now, there's the only iostream implementation - plain iostream
without any processing - but we may add other implementations in future.

Apart from introducing the iostream struct, this patch also makes coio
helpers use it. From now on, coio read/write methods take iostream
instead of ev_io and create ev_io internally (in coio_wait). This is
fine, because creation of a new ev_io on stack is cheap.

Basically, this patch updates all coio users so that they call
iostream_create and iostream_close instead of coio_create and
coio_close_io. Plus, it adds a call to iostream_destroy, because in
contrast to ev_io, iostream must be destroyed explicitly.
parent f35c647a
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment