session_t now holds a std::auto_prt<journal_t>

This commit is contained in:
John Wiegley 2009-11-12 03:32:10 -05:00
parent b5dca67396
commit b2b0ae37e8
4 changed files with 19 additions and 19 deletions

View file

@ -201,23 +201,23 @@ bool archive_t::should_load(const std::list<path>& data_files)
return true; return true;
} }
bool archive_t::should_save(shared_ptr<journal_t> journal) bool archive_t::should_save(journal_t& journal)
{ {
std::list<path> data_files; std::list<path> data_files;
DEBUG("archive.journal", "Should the archive be saved?"); DEBUG("archive.journal", "Should the archive be saved?");
if (journal->was_loaded) { if (journal.was_loaded) {
DEBUG("archive.journal", "No, it's one we loaded before"); DEBUG("archive.journal", "No, it's one we loaded before");
return false; return false;
} }
if (journal->sources.empty()) { if (journal.sources.empty()) {
DEBUG("archive.journal", "No, there were no sources!"); DEBUG("archive.journal", "No, there were no sources!");
return false; return false;
} }
foreach (const journal_t::fileinfo_t& i, journal->sources) { foreach (const journal_t::fileinfo_t& i, journal.sources) {
if (i.from_stream) { if (i.from_stream) {
DEBUG("archive.journal", "No, one source was from a stream"); DEBUG("archive.journal", "No, one source was from a stream");
return false; return false;
@ -241,14 +241,14 @@ bool archive_t::should_save(shared_ptr<journal_t> journal)
return true; return true;
} }
void archive_t::save(shared_ptr<journal_t> journal) void archive_t::save(journal_t& journal)
{ {
INFO_START(archive, "Saved journal file cache"); INFO_START(archive, "Saved journal file cache");
ofstream stream(file, std::ios::binary); ofstream stream(file, std::ios::binary);
write_header_bits(stream); write_header_bits(stream);
sources = journal->sources; sources = journal.sources;
#if defined(DEBUG_ON) #if defined(DEBUG_ON)
foreach (const journal_t::fileinfo_t& i, sources) foreach (const journal_t::fileinfo_t& i, sources)
@ -263,12 +263,12 @@ void archive_t::save(shared_ptr<journal_t> journal)
DEBUG("archive.journal", DEBUG("archive.journal",
"Archiving journal with " << sources.size() << " sources"); "Archiving journal with " << sources.size() << " sources");
oa << *journal; oa << journal;
INFO_FINISH(archive); INFO_FINISH(archive);
} }
bool archive_t::load(shared_ptr<journal_t> journal) bool archive_t::load(journal_t& journal)
{ {
INFO_START(archive, "Read cached journal file"); INFO_START(archive, "Read cached journal file");
@ -282,8 +282,8 @@ bool archive_t::load(shared_ptr<journal_t> journal)
archive_t temp; archive_t temp;
iarchive >> temp; iarchive >> temp;
iarchive >> *journal.get(); iarchive >> journal;
journal->was_loaded = true; journal.was_loaded = true;
INFO_FINISH(archive); INFO_FINISH(archive);

View file

@ -69,10 +69,10 @@ public:
bool read_header(); bool read_header();
bool should_load(const std::list<path>& data_files); bool should_load(const std::list<path>& data_files);
bool should_save(shared_ptr<journal_t> journal); bool should_save(journal_t& journal);
void save(shared_ptr<journal_t> journal); void save(journal_t& journal);
bool load(shared_ptr<journal_t> journal); bool load(journal_t& journal);
#if defined(HAVE_BOOST_SERIALIZATION) #if defined(HAVE_BOOST_SERIALIZATION)
private: private:

View file

@ -106,7 +106,7 @@ std::size_t session_t::read_data(const string& master_account)
if (! (cache && if (! (cache &&
cache->should_load(HANDLER(file_).data_files) && cache->should_load(HANDLER(file_).data_files) &&
cache->load(journal))) { cache->load(*journal.get()))) {
#endif // HAVE_BOOST_SERIALIZATION #endif // HAVE_BOOST_SERIALIZATION
if (price_db_path) { if (price_db_path) {
if (exists(*price_db_path)) { if (exists(*price_db_path)) {
@ -142,8 +142,8 @@ std::size_t session_t::read_data(const string& master_account)
assert(xact_count == journal->xacts.size()); assert(xact_count == journal->xacts.size());
#if defined(HAVE_BOOST_SERIALIZATION) #if defined(HAVE_BOOST_SERIALIZATION)
if (cache && cache->should_save(journal)) if (cache && cache->should_save(*journal.get()))
cache->save(journal); cache->save(*journal.get());
} }
#endif // HAVE_BOOST_SERIALIZATION #endif // HAVE_BOOST_SERIALIZATION

View file

@ -58,9 +58,9 @@ class session_t : public symbol_scope_t
friend void set_session_context(session_t * session); friend void set_session_context(session_t * session);
public: public:
bool flush_on_next_data_file; bool flush_on_next_data_file;
date_t::year_type current_year; date_t::year_type current_year;
shared_ptr<journal_t> journal; std::auto_ptr<journal_t> journal;
explicit session_t(); explicit session_t();
virtual ~session_t() { virtual ~session_t() {