Re: help! anyone knows how to improve STL multi-thread synch?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Tom Widmer [VC++ MVP] wrote:
That is not the correct way to redirect cout. Instead, try:

int main()
{
std::filebuf fb;
fb.open("logfile.txt", std::ios_base::out);
std::streambuf* oldcout = std::cout.rdbuf(&fb);
// rest of program

//must reset before exit:
std::cout.rdbuf(oldcout);
}

Sorry for the side-question, but why does one need to reset the old rdbuf? Is it to prevent a memory leak?

Jason
.



Relevant Pages

  • Re: Threading / Event issue...
    ... I was considering whether the event might be set and reset before the thread ... You should also *wait for the chime thread to exit* in the main thread ... before firing another instance for the new time-out. ... event signals a Control Panel setting change, one signals a change in the ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: p630 hangup
    ... It can be difficult to deal with this sort of problem. ... Usually a reset is ... If it's a memory leak, there are some IBM tools to help diagnose them. ... in some more intrusive monitoring. ...
    (AIX-L)
  • Re: "file locked by another user" mystery
    ... > $ RESET:= ON ERROR THEN RESET ... >> something other than ON ERROR THEN EXIT? ... you can redefine "EXIT" as a DCL SYMBOL. ... another DCL procedure, what would not be practical about it? ...
    (comp.os.vms)
  • Re: sum of array
    ... what does your simulation say the values of s, s, ... Port (clk: in STD_LOGIC; ... reset: in STD_LOGIC; ... exit SEQ_LOOP when reset = '1'; ...
    (comp.arch.fpga)
  • Re: how to saft exit the application
    ... user wont be doing anything as you are busy doing something. ... > I compose a application (with hidden GUI) to do something and exit ... there are also some memory leak. ... > AfxGetApp()->OnAppExit() to exit the application, ...
    (microsoft.public.vc.mfc)