inetbot web crawler
Main  |  Get access to the repository  |  API  |  The robot  |  Publications  |  Usenet Groups  |  Plainweb  | 
 inetbot - Groups (beta)

Current group: comp.object

Controlling ofstream buffering?

Controlling ofstream buffering?  
idesilva at eudoramail.com
 Re: Controlling ofstream buffering?  
Robert Klemme
 Re: Controlling ofstream buffering?  
idesilva at eudoramail.com
From:idesilva at eudoramail.com
Subject:Controlling ofstream buffering?
Date:17 Jan 2005 00:25:11 -0800
Hi,

I have an app that generates a text log at a very high rate. Currently
I use an ofstream object to write the log. I would like to control when
'exactly' the log is written to the disk. Also I want to be able to
reset the buffer contents without writing them to the disk file.

- Can the 'buffer size' of an ofstream object (in fact, any stream
object) be controlled?
- Can we control *when* the buffer is flushed? [I want ofstream to
flush *only* when I invoke flush(). The default 'nounitbuf' behavior
doesn't do what I want]
- Is there a way to *reset* the ofstream buffer?

Thanks,
Ishan.
From:Robert Klemme
Subject:Re: Controlling ofstream buffering?
Date:Mon, 17 Jan 2005 17:43:38 +0100

schrieb im Newsbeitrag
news:1105950311.949682.124190@c13g2000cwb.googlegroups.com...
> Hi,
>
> I have an app that generates a text log at a very high rate. Currently
> I use an ofstream object to write the log. I would like to control when
> 'exactly' the log is written to the disk. Also I want to be able to
> reset the buffer contents without writing them to the disk file.
>
> - Can the 'buffer size' of an ofstream object (in fact, any stream
> object) be controlled?

Only on creation.

> - Can we control *when* the buffer is flushed? [I want ofstream to
> flush *only* when I invoke flush(). The default 'nounitbuf' behavior
> doesn't do what I want]

You can additionally flush the stream, but you cannot prevent a flush when
the buffer is full.

> - Is there a way to *reset* the ofstream buffer?

Nope.

You'll have to roll your own stream class. But that's not too difficult.

Regards

robert
From:idesilva at eudoramail.com
Subject:Re: Controlling ofstream buffering?
Date:18 Jan 2005 01:14:47 -0800
Thanks.
   

Copyright © 2006 inetbot   -   All rights reserved