Re: [GIO] Using GBufferedOutputStream



(Replying to myself)

On 7 April 2011 12:24, Ayo <ayo blicky net> wrote:
[snip]
- Will GBufferedOutputStream correctly handle the situation where new
data is added to the buffer while it is performing a flush operation
on the background? I've skimmed a bit through the code, but get the
impression it is not supposed to be used like this.

Learned what happens after some experimentation: the
g_output_stream_write() will fail with "Stream has outstanding
operation", thus not even allowing new writes to the buffer while it
is flushing. This confirms that I'm using it in a way it is not
supposed to be used.

I also just encountered a problem with g_output_stream_write(): in
some situations, it reports to have written less bytes than I asked it
to. I had assumed this to be impossible when writing to an
auto-growing buffer. I have not investigated this problem any furher
yet, though, and have no idea whether it is related to the above
problem.

Also solved this mistery. This was caused by a bug in my code and
_write() was called with an already unref()'ed GOutputStream.

[snip]

I keep wondering if there is no better solution to do this, and how
GBufferedOutputStream *is* supposed to be used...

While I'm still wondering how (or more importantly: when)
GBufferedOutputStream is supposed to be used, it apparently isn't what
I was looking for. Implementing my own buffer seems like the best
option...

On a related note: why are all these high-level I/O modules using
threads for async operations, rather than using the main loop for
polling the underlying filehandles (where possible). That would be
both more efficient and allows better cancellation. I'm inclined to
fall back to plain old socket programming with all these levels of
indirection, added complexity and inefficiencies. :-(

Ayo



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