U
Uwe Ludolf
Guest
I've written a little tool that recursively scans directories to make the parts between the "."s of the file uppercase or lowercase if they were completely lowercase or uppercase before. This tool works optionaly with a thread for each directory (this really gives a speed improvement). As I can't output directly to wcout or wcerr frrom an arbitrary thread, the output is done by this function:
#if defined(OUTPUT_WORKAROUND)
#include <cstdio>
#endif
void writeOutput( wostream &wos, wchar_t const *str )
{
static mutex mtx;
lock_guard<mutex> lock( mtx );
#if !defined(OUTPUT_WORKAROUND)
wos << err << endl;
#else
fwprintf( &wos == &wcout ? stdout : stderr, L"%s\n", str );
#endif
}
If I don't do the OUTPUT_WORKAROUND, the output stops after several thousand lines but the program continues processing, i.e. the operator << returns but there won't be further outputs. This is obviously a runtime-lib bug. BTW: It doesn't matter if I actually issue the output from different threads or all from a single thread.
Continue reading...
#if defined(OUTPUT_WORKAROUND)
#include <cstdio>
#endif
void writeOutput( wostream &wos, wchar_t const *str )
{
static mutex mtx;
lock_guard<mutex> lock( mtx );
#if !defined(OUTPUT_WORKAROUND)
wos << err << endl;
#else
fwprintf( &wos == &wcout ? stdout : stderr, L"%s\n", str );
#endif
}
If I don't do the OUTPUT_WORKAROUND, the output stops after several thousand lines but the program continues processing, i.e. the operator << returns but there won't be further outputs. This is obviously a runtime-lib bug. BTW: It doesn't matter if I actually issue the output from different threads or all from a single thread.
Continue reading...