Flushing of an output stream handled by the stream itself



Hi,

is there any class in GLib, GIO etc. which provides automatic content
flushing (e.g. an output stream associated with a socket) that would be
fully asynchronous, working in "background" and would accept multiple
subsequent write requests without risk of blocking?

The g_output_stream_write_async() documentation mentions that "During an
async request no other sync and async calls are allowed, and will result
in G_IO_ERROR_PENDING errors"[1]. So it looks like I have to gather the
result using g_output_stream_write_finish() after every write_async
call.

For example, libevent has evbuffers[2] which accept multiple subsequent
write requests and flush data to a socket internally in the library's
event loop.

Is there anything like evbuffers in GLib/GIO or do I have to implement
it myself? Should I implement it using some kind of queue and manage one
async write request at a time?


[1] https://developer.gnome.org/gio/stable/GOutputStream.html#g-output-stream-write-async
[2] http://www.wangafu.net/~nickm/libevent-book/Ref7_evbuffer.html

-- 
Marcin Szewczyk
http://wodny.org


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]