void Journal::journal(const AlignedBuilder& b) { try { mutex::scoped_lock lk(_lfMutex); if( _lf == 0 ) open(); written += b.len(); _lf->synchronousAppend((void *) b.buf(), b.len()); } catch(std::exception& e) { log() << "warning exception in dur::journal " << e.what() << endl; } }
/* threading: only durThread() calls this, thus safe. */ void Journal::open() { mutex::scoped_lock lk(_lfMutex); assert( _lf == 0 ); string fname = getFilePathFor(nextFileNumber).string(); _lf = new LogFile(fname); nextFileNumber++; { JHeader h(fname); AlignedBuilder b(8192); b.appendStruct(h); _lf->synchronousAppend(b.buf(), b.len()); } }