> > I would suggest you use a MMF instead. This is the fastest
> way to write
> to
> > a file, plus you'll have all the data the program writes to the file
> before
> > it dies.
>
> I've had cases where that's not true. If the memory manager
> doesn't get
> around to writing the dirty pages to the file *or* if for
> some reason the
> system chokes hard enough your file will be there but with a
> zero length
> (yes, I've had that happen numerous times). The best
> guarantee is with an
> IO that completes so you know that the log data is safely at it's
> destination.
I also thought I've seen large delays sometimes with MMF, particularly
the first access. I think I remember when I was optimizing my code that
I'd take a big hit the first time I *wrote* to a MMF. That's why I
didn't do that at first.
But in any case, because of the warning you gave above, I won't change
my class to do it that way!
I was thinking there should be a way to get control if the program was
about to crash, then write the file. I don't see exactly how to do it,
though. I found the set_terminate() function, but I'm not sure that does
exactly what I want.
It claims that each thread needs to set its own set_terminate(). I
understand that as meaning that if a worker thread crashes, and I only
did a set_terminate() in the UI thread, that it wouldn't get called. Is
that true?
Also, as a more fundamental question (exposing my ignorance even more!),
is everything that makes a program crash an exception that gets caught
by the routine that calls the terminate function, or does this only work
when something calls "throw"?