mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-09 04:59:31 -06:00
merge set_active_revision() with commit()
This commit is contained in:
@@ -528,12 +528,6 @@ object PgfDB::get_active_revision()
|
||||
return current_db->ms->active_revision;
|
||||
}
|
||||
|
||||
PGF_INTERNAL
|
||||
void PgfDB::set_active_revision(object o)
|
||||
{
|
||||
current_db->ms->active_revision = o;
|
||||
}
|
||||
|
||||
PGF_INTERNAL
|
||||
int PgfDB::init_state()
|
||||
{
|
||||
@@ -1181,17 +1175,19 @@ void PgfDB::start_transaction()
|
||||
}
|
||||
|
||||
PGF_INTERNAL
|
||||
void PgfDB::commit()
|
||||
void PgfDB::commit(object o)
|
||||
{
|
||||
malloc_state *ms = current_db->ms;
|
||||
object save_top = ms->top;
|
||||
object save_free_blocks = ms->free_blocks;
|
||||
object save_free_descriptors = ms->free_descriptors;
|
||||
object save_active_revision = ms->active_revision;
|
||||
|
||||
int res;
|
||||
#ifndef _WIN32
|
||||
#ifndef MREMAP_MAYMOVE
|
||||
if (current_db->fd < 0) {
|
||||
ms->active_revision = o;
|
||||
ms->top = top;
|
||||
ms->free_blocks = free_blocks;
|
||||
if (free_descriptors[2] != 0) {
|
||||
@@ -1216,6 +1212,7 @@ void PgfDB::commit()
|
||||
if (res != 0)
|
||||
throw pgf_systemerror(errno);
|
||||
|
||||
ms->active_revision = o;
|
||||
ms->top = top;
|
||||
ms->free_blocks = free_blocks;
|
||||
ms->free_descriptors = free_descriptors[0];
|
||||
@@ -1223,6 +1220,7 @@ void PgfDB::commit()
|
||||
|
||||
res = msync((void *) ms, page_size, MS_SYNC | MS_INVALIDATE);
|
||||
if (res != 0) {
|
||||
ms->active_revision = save_active_revision;
|
||||
ms->top = save_top;
|
||||
ms->free_blocks = save_free_blocks;
|
||||
ms->free_descriptors = save_free_descriptors;
|
||||
@@ -1244,11 +1242,13 @@ void PgfDB::commit()
|
||||
if (!FlushViewOfFile(base,mmap_size)) {
|
||||
throw pgf_systemerror(last_error_to_errno());
|
||||
}
|
||||
ms->active_revision = o;
|
||||
ms->top = top;
|
||||
ms->free_blocks = free_blocks;
|
||||
ms->free_descriptors = free_descriptors[0];
|
||||
ms->curr_txn_id++;
|
||||
if (!FlushViewOfFile(ms,page_size)) {
|
||||
ms->active_revision = save_active_revision;
|
||||
ms->top = save_top;
|
||||
ms->free_blocks = save_free_blocks;
|
||||
ms->free_descriptors = save_free_descriptors;
|
||||
|
||||
@@ -113,7 +113,6 @@ public:
|
||||
PGF_INTERNAL_DECL void cleanup_revisions();
|
||||
|
||||
PGF_INTERNAL_DECL object get_active_revision();
|
||||
PGF_INTERNAL_DECL void set_active_revision(object o);
|
||||
PGF_INTERNAL_DECL void register_revision(object o);
|
||||
PGF_INTERNAL_DECL void unregister_revision(object o);
|
||||
|
||||
@@ -121,7 +120,7 @@ public:
|
||||
PGF_INTERNAL_DECL ref<PgfConcr> revision2concr(PgfConcrRevision revision);
|
||||
|
||||
PGF_INTERNAL_DECL void start_transaction();
|
||||
PGF_INTERNAL_DECL void commit();
|
||||
PGF_INTERNAL_DECL void commit(object o);
|
||||
PGF_INTERNAL_DECL void rollback();
|
||||
|
||||
private:
|
||||
|
||||
@@ -59,10 +59,8 @@ PgfDB *pgf_read_pgf(const char* fpath,
|
||||
PgfReader rdr(in);
|
||||
ref<PgfPGF> pgf = rdr.read_pgf();
|
||||
|
||||
db->set_active_revision(pgf.as_object());
|
||||
db->register_revision(*revision = pgf.tagged());
|
||||
|
||||
db->commit();
|
||||
db->commit(pgf.as_object());
|
||||
}
|
||||
|
||||
db->ref_count++;
|
||||
@@ -108,10 +106,8 @@ PgfDB *pgf_boot_ngf(const char* pgf_path, const char* ngf_path,
|
||||
PgfReader rdr(in);
|
||||
ref<PgfPGF> pgf = rdr.read_pgf();
|
||||
|
||||
db->set_active_revision(pgf.as_object());
|
||||
db->register_revision(*revision = pgf.tagged());
|
||||
|
||||
db->commit();
|
||||
db->commit(pgf.as_object());
|
||||
}
|
||||
|
||||
db->ref_count++;
|
||||
@@ -190,10 +186,8 @@ PgfDB *pgf_new_ngf(PgfText *abstract_name,
|
||||
pgf->abstract.funs = 0;
|
||||
pgf->abstract.cats = 0;
|
||||
pgf->concretes = 0;
|
||||
db->set_active_revision(pgf.as_object());
|
||||
db->register_revision(*revision = pgf.tagged());
|
||||
|
||||
db->commit();
|
||||
db->commit(pgf.as_object());
|
||||
}
|
||||
|
||||
db->ref_count++;
|
||||
@@ -1098,9 +1092,7 @@ void pgf_commit_transaction(PgfDB *db, PgfRevision revision,
|
||||
DB_scope scope(db, WRITER_SCOPE);
|
||||
|
||||
ref<PgfPGF> new_pgf = db->revision2pgf(revision);
|
||||
db->set_active_revision(new_pgf.as_object());
|
||||
|
||||
db->commit();
|
||||
db->commit(new_pgf.as_object());
|
||||
} PGF_API_END
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user