# # # patch "cmd_conflicts.cc" # from [6bc6f92f1e233d26271ad61d32fa7d355d35a585] # to [74192646e041e0e51cdcb719facc64ed3d2a199b] # # patch "cmd_merging.cc" # from [8253dd6a55ffc02d922f4dc21b634802a1ac5a2d] # to [b635712c6fb571f71f49e203496f0337beb848d5] # # patch "database.cc" # from [c6ab3d8eaef1299724b739a97b07ffb1d3a3cb7b] # to [7d4d73d6373f4d66a01a960a4d6f20fe75574b04] # # patch "database.hh" # from [e3de5162c6654e1355444eb0d6c4d8bd6c0fe63b] # to [56382d629c35fb7c9f3444358a3d59e62e127e69] # # patch "intrusive_ptr.hh" # from [fab77279c4bd359d34092b0386576cfe7a274ac2] # to [25223ff309bd86c8a66768b4b78c13ec294b5b60] # # patch "merge_conflict.cc" # from [bcc2018db31c73b7a6a63135e42095127217951d] # to [f2e977a619fc2b80a046f698e8ac898cf33d4081] # # patch "merge_content.cc" # from [b7b36faae51fad93a1b7ba37c17eee7bb20dd5a9] # to [812c98c273a631e50a413f08bf19e16538c19908] # # patch "merge_content.hh" # from [f686979a4a2f6af3912880b91d8c9fea3be2db06] # to [3d5fc9049a8b0ad4843be89c462b70cc979c43bf] # # patch "merge_roster.hh" # from [c721929e38b641375ea2b5ac1ae2fdd081e88882] # to [72c9ecaadb606f9d6a7bb6d0df2b057f0f366115] # # patch "migrate_ancestry.cc" # from [c02341580f9e65387807dc8f1ae3874d26e81198] # to [7b271fb749e27230558554db15961ab9ca9900ee] # # patch "restrictions.hh" # from [cbbc558507e794f658622f153ebda63b1b5ea039] # to [1614d7a25729db50e506527ee1d3889e76006003] # # patch "rev_types.hh" # from [57f8ea1d809f63101811a9c816f413b3fa912872] # to [af6493b1e40fbc2ef447aad689a5203747b23a7b] # # patch "revision.hh" # from [75bac531320de250cc7d0660762c3b01e04147dd] # to [8a319bd419729009989da49fdf0d1042981b6888] # # patch "roster.hh" # from [f79fe7c3e150abe91f2497421a71eacbd0145d60] # to [52c178b2e61e71b366d6d0300f02c3fe8e09d24f] # # patch "work.cc" # from [766cbbfd5b78c442ed6fc650846daa55f9d42768] # to [fd3ac41716a28199abc492b669bfff5550ece406] # # patch "work.hh" # from [d6167a82e9e8fefa17d892c09af2ed0c78f8ded5] # to [0282f5fd5c21280eeab004179aaba984ecfc09d8] # ============================================================ --- cmd_conflicts.cc 6bc6f92f1e233d26271ad61d32fa7d355d35a585 +++ cmd_conflicts.cc 74192646e041e0e51cdcb719facc64ed3d2a199b @@ -23,14 +23,14 @@ struct conflicts_t { roster_merge_result result; revision_id ancestor_rid, left_rid, right_rid; - boost::shared_ptr ancestor_roster; - boost::shared_ptr left_roster; - boost::shared_ptr right_roster; + boost::intrusive_ptr ancestor_roster; + boost::intrusive_ptr left_roster; + boost::intrusive_ptr right_roster; marking_map left_marking, right_marking; conflicts_t(database & db, bookkeeping_path const & file): - left_roster(boost::shared_ptr(new roster_t())), - right_roster(boost::shared_ptr(new roster_t())) + left_roster(boost::intrusive_ptr(new roster_t())), + right_roster(boost::intrusive_ptr(new roster_t())) { result.clear(); // default constructor doesn't do this. @@ -182,7 +182,7 @@ do_interactive_merge(database & db, if (!conflicts.ancestor_roster) { - conflicts.ancestor_roster = boost::shared_ptr(new roster_t()); + conflicts.ancestor_roster = boost::intrusive_ptr(new roster_t()); db.get_roster(conflicts.ancestor_rid, *conflicts.ancestor_roster); } ============================================================ --- cmd_merging.cc 8253dd6a55ffc02d922f4dc21b634802a1ac5a2d +++ cmd_merging.cc b635712c6fb571f71f49e203496f0337beb848d5 @@ -40,7 +40,7 @@ using std::strlen; using std::vector; using std::strlen; -using boost::shared_ptr; +using boost::intrusive_ptr; static void add_dormant_attrs(node_t const parent, node_t child) @@ -287,7 +287,7 @@ CMD(update, "update", "", CMD_REF(worksp = parent_cached_roster(parents.begin()).first; MM(*old_roster); - shared_ptr working_roster = shared_ptr(new roster_t()); + intrusive_ptr working_roster(new roster_t()); MM(*working_roster); work.get_current_roster_shape(db, nis, *working_roster); @@ -746,7 +746,7 @@ CMD(merge_into_workspace, "merge_into_wo { revision_id left_id, right_id; cached_roster left, right; - shared_ptr working_roster = shared_ptr(new roster_t()); + intrusive_ptr working_roster = intrusive_ptr(new roster_t()); if (args.size() != 1) throw usage(execid); @@ -955,8 +955,8 @@ show_conflicts_core (database & db, return; } - shared_ptr l_roster = shared_ptr(new roster_t()); - shared_ptr r_roster = shared_ptr(new roster_t()); + intrusive_ptr l_roster = intrusive_ptr(new roster_t()); + intrusive_ptr r_roster = intrusive_ptr(new roster_t()); marking_map l_marking, r_marking; db.get_roster(l_id, *l_roster, l_marking); db.get_roster(r_id, *r_roster, r_marking); @@ -1163,7 +1163,7 @@ CMD_AUTOMATE(file_merge, N_("LEFT_REVID revision_id ancestor_rid; file_path ancestor_path; file_id ancestor_fid; - shared_ptr ancestor_roster; + intrusive_ptr ancestor_roster; adaptor.get_ancestral_roster(left_n->self, ancestor_rid, ancestor_roster); ancestor_roster->get_file_details(left_n->self, ancestor_fid, ancestor_path); @@ -1252,12 +1252,12 @@ CMD(pluck, "pluck", "", CMD_REF(workspac temp_node_id_source nis; // Get the FROM roster - shared_ptr from_roster = shared_ptr(new roster_t()); + intrusive_ptr from_roster = intrusive_ptr(new roster_t()); MM(*from_roster); db.get_roster(from_rid, *from_roster); // Get the WORKING roster - shared_ptr working_roster = shared_ptr(new roster_t()); + intrusive_ptr working_roster = intrusive_ptr(new roster_t()); MM(*working_roster); work.get_current_roster_shape(db, nis, *working_roster); @@ -1284,7 +1284,7 @@ CMD(pluck, "pluck", "", CMD_REF(workspac } E(!from_to_to.empty(), origin::user, F("no changes to be applied")); // ...and use it to create the TO roster - shared_ptr to_roster = shared_ptr(new roster_t()); + intrusive_ptr to_roster = intrusive_ptr(new roster_t()); MM(*to_roster); { *to_roster = *from_roster; ============================================================ --- database.cc c6ab3d8eaef1299724b739a97b07ffb1d3a3cb7b +++ database.cc 7d4d73d6373f4d66a01a960a4d6f20fe75574b04 @@ -2047,7 +2047,7 @@ database::get_roster_version(revision_id selected_path.pop_back(); // we know that this isn't already in the cache (because of the early exit // above), so we should create new objects and spend time filling them in. - shared_ptr roster(new roster_t); + intrusive_ptr roster(new roster_t); shared_ptr marking(new marking_map); imp->get_roster_base(revision_id(curr), *roster, *marking); @@ -2741,7 +2741,7 @@ database::put_roster_for_revision(revisi { // Construct, the roster, sanity-check the manifest id, and then write it // to the db - shared_ptr ros_writeable(new roster_t); MM(*ros_writeable); + intrusive_ptr ros_writeable(new roster_t); MM(*ros_writeable); shared_ptr mm_writeable(new marking_map); MM(*mm_writeable); manifest_id roster_manifest_id; MM(roster_manifest_id); ============================================================ --- database.hh e3de5162c6654e1355444eb0d6c4d8bd6c0fe63b +++ database.hh 56382d629c35fb7c9f3444358a3d59e62e127e69 @@ -17,6 +17,7 @@ #include #include "rev_types.hh" +#include "roster.hh" // parent_map #include "cert.hh" class app_state; ============================================================ --- intrusive_ptr.hh fab77279c4bd359d34092b0386576cfe7a274ac2 +++ intrusive_ptr.hh 25223ff309bd86c8a66768b4b78c13ec294b5b60 @@ -14,9 +14,9 @@ #include "sanity.hh" // By convention, intrusively reference-counted objects should have a -// private member of type intrusive_refcnt_t, named "refcnt", and be -// friends with these functions. Since monotone is single-threaded, -// we do not worry about locking. +// private member of type "mutable intrusive_refcnt_t", named +// "refcnt", and be friends with these functions. Since monotone is +// single-threaded, we do not worry about locking. typedef long intrusive_refcnt_t; @@ -34,6 +34,24 @@ template inline void intrusive delete ptr; } +// It is necessary to reiterate the above definitions for a +// pointer to T const. + +template inline void intrusive_ptr_add_ref(T const * ptr) +{ + ptr->refcnt++; + I(ptr->refcnt > 0); +} + +template inline void intrusive_ptr_release(T const * ptr) +{ + ptr->refcnt--; + I(ptr->refcnt >= 0); + if (ptr->refcnt == 0) + delete ptr; +} + + // This base class takes care of the above conventions for you. // Note that intrusive_ptr_add_ref/release still need to be template // functions, as one must apply delete to a pointer with the true type @@ -41,10 +59,12 @@ class intrusively_refcounted class intrusively_refcounted { - intrusive_refcnt_t refcnt; + mutable intrusive_refcnt_t refcnt; // sadly, no way to say "any subclass of this" template friend void intrusive_ptr_add_ref(T *); template friend void intrusive_ptr_release(T *); + template friend void intrusive_ptr_add_ref(T const *); + template friend void intrusive_ptr_release(T const *); public: intrusively_refcounted() : refcnt(0) {} }; ============================================================ --- merge_conflict.cc bcc2018db31c73b7a6a63135e42095127217951d +++ merge_conflict.cc f2e977a619fc2b80a046f698e8ac898cf33d4081 @@ -22,6 +22,7 @@ using boost::shared_ptr; using std::make_pair; using std::string; using boost::shared_ptr; +using boost::intrusive_ptr; namespace { @@ -103,7 +104,7 @@ put_added_conflict_left(basic_io::stanza // access functions to content_merge_adaptor. content_merge_database_adaptor & db_adaptor (dynamic_cast(adaptor)); - boost::shared_ptr roster(db_adaptor.rosters[db_adaptor.left_rid]); + boost::intrusive_ptr roster(db_adaptor.rosters[db_adaptor.left_rid]); file_path name; roster->get_name (nid, name); @@ -129,7 +130,7 @@ put_added_conflict_right(basic_io::stanz node_id const nid) { content_merge_database_adaptor & db_adaptor (dynamic_cast(adaptor)); - boost::shared_ptr roster(db_adaptor.rosters[db_adaptor.right_rid]); + boost::intrusive_ptr roster(db_adaptor.rosters[db_adaptor.right_rid]); I(0 != roster); file_path name; @@ -158,9 +159,9 @@ put_rename_conflict_left(basic_io::stanz node_id const nid) { content_merge_database_adaptor & db_adaptor (dynamic_cast(adaptor)); - boost::shared_ptr ancestor_roster(db_adaptor.rosters[db_adaptor.lca]); + boost::intrusive_ptr ancestor_roster(db_adaptor.rosters[db_adaptor.lca]); I(0 != ancestor_roster); - boost::shared_ptr left_roster(db_adaptor.rosters[db_adaptor.left_rid]); + boost::intrusive_ptr left_roster(db_adaptor.rosters[db_adaptor.left_rid]); file_path ancestor_name; file_path left_name; @@ -285,9 +286,9 @@ put_rename_conflict_right (basic_io::sta node_id const nid) { content_merge_database_adaptor & db_adaptor (dynamic_cast(adaptor)); - boost::shared_ptr ancestor_roster(db_adaptor.rosters[db_adaptor.lca]); + boost::intrusive_ptr ancestor_roster(db_adaptor.rosters[db_adaptor.lca]); I(0 != ancestor_roster); - boost::shared_ptr right_roster(db_adaptor.rosters[db_adaptor.right_rid]); + boost::intrusive_ptr right_roster(db_adaptor.rosters[db_adaptor.right_rid]); I(0 != right_roster); file_path ancestor_name; @@ -344,13 +345,13 @@ put_attr_conflict (basic_io::stanza & st content_merge_database_adaptor & db_adaptor (dynamic_cast(adaptor)); // This ensures that the ancestor roster is computed - boost::shared_ptr ancestor_roster; + boost::intrusive_ptr ancestor_roster; revision_id ancestor_rid; db_adaptor.get_ancestral_roster (conflict.nid, ancestor_rid, ancestor_roster); - boost::shared_ptr left_roster(db_adaptor.rosters[db_adaptor.left_rid]); + boost::intrusive_ptr left_roster(db_adaptor.rosters[db_adaptor.left_rid]); I(0 != left_roster); - boost::shared_ptr right_roster(db_adaptor.rosters[db_adaptor.right_rid]); + boost::intrusive_ptr right_roster(db_adaptor.rosters[db_adaptor.right_rid]); I(0 != right_roster); file_path ancestor_name; @@ -460,7 +461,7 @@ put_content_conflict (basic_io::stanza & content_merge_database_adaptor & db_adaptor (dynamic_cast(adaptor)); // This ensures that the ancestor roster is computed - boost::shared_ptr ancestor_roster; + boost::intrusive_ptr ancestor_roster; revision_id ancestor_rid; db_adaptor.get_ancestral_roster (conflict.nid, ancestor_rid, ancestor_roster); @@ -555,7 +556,7 @@ roster_merge_result::report_missing_root // these must be different for this conflict to happen I(left_root != right_root); - shared_ptr left_lca_roster, right_lca_roster; + intrusive_ptr left_lca_roster, right_lca_roster; revision_id left_lca_rid, right_lca_rid; file_path left_lca_name, right_lca_name; @@ -686,7 +687,7 @@ roster_merge_result::report_invalid_name I(!roster.is_attached(conflict.nid)); - shared_ptr lca_roster, parent_lca_roster; + intrusive_ptr lca_roster, parent_lca_roster; revision_id lca_rid, parent_lca_rid; file_path lca_name, lca_parent_name; basic_io::stanza st; @@ -796,7 +797,7 @@ roster_merge_result::report_directory_lo left_roster.get_name(conflict.parent_name.first, left_parent_name); right_roster.get_name(conflict.parent_name.first, right_parent_name); - shared_ptr lca_roster; + intrusive_ptr lca_roster; revision_id lca_rid; file_path lca_name, lca_parent_name; basic_io::stanza st; @@ -868,7 +869,7 @@ roster_merge_result::report_orphaned_nod I(!roster.is_attached(conflict.nid)); - shared_ptr lca_roster, parent_lca_roster; + intrusive_ptr lca_roster, parent_lca_roster; revision_id lca_rid, parent_lca_rid; file_path lca_name; @@ -1011,7 +1012,7 @@ roster_merge_result::report_multiple_nam left_roster.get_name(conflict.nid, left_name); right_roster.get_name(conflict.nid, right_name); - shared_ptr lca_roster; + intrusive_ptr lca_roster; revision_id lca_rid; file_path lca_name; @@ -1074,7 +1075,7 @@ roster_merge_result::report_duplicate_na left_roster.get_name(left_nid, left_name); right_roster.get_name(right_nid, right_name); - shared_ptr left_lca_roster, right_lca_roster; + intrusive_ptr left_lca_roster, right_lca_roster; revision_id left_lca_rid, right_lca_rid; adaptor.get_ancestral_roster(left_nid, left_lca_rid, left_lca_roster); @@ -1289,7 +1290,7 @@ roster_merge_result::report_attribute_co left_roster.get_name(conflict.nid, left_name); right_roster.get_name(conflict.nid, right_name); - shared_ptr lca_roster; + intrusive_ptr lca_roster; revision_id lca_rid; file_path lca_name; @@ -1355,7 +1356,7 @@ namespace roster_t const & right_roster) { revision_id ancestor_rid; - shared_ptr ancestor_roster; + intrusive_ptr ancestor_roster; adaptor.get_ancestral_roster(conflict.nid, ancestor_rid, ancestor_roster); I(ancestor_roster); @@ -1427,7 +1428,7 @@ roster_merge_result::report_file_content left_roster.get_name(conflict.nid, left_name); right_roster.get_name(conflict.nid, right_name); - shared_ptr lca_roster; + intrusive_ptr lca_roster; revision_id lca_rid; file_path lca_name; @@ -1459,7 +1460,7 @@ namespace resolve_conflicts file_id & merged_id) { revision_id ancestor_rid; - shared_ptr ancestor_roster; + intrusive_ptr ancestor_roster; adaptor.get_ancestral_roster(conflict.nid, ancestor_rid, ancestor_roster); I(ancestor_roster); @@ -2114,9 +2115,9 @@ roster_merge_result::write_conflict_file revision_id const & ancestor_rid, revision_id const & left_rid, revision_id const & right_rid, - boost::shared_ptr left_roster, + boost::intrusive_ptr left_roster, marking_map const & left_marking, - boost::shared_ptr right_roster, + boost::intrusive_ptr right_roster, marking_map const & right_marking) { std::ostringstream output; ============================================================ --- merge_content.cc b7b36faae51fad93a1b7ba37c17eee7bb20dd5a9 +++ merge_content.cc 812c98c273a631e50a413f08bf19e16538c19908 @@ -33,6 +33,7 @@ using boost::shared_ptr; using std::string; using std::vector; using boost::shared_ptr; +using boost::intrusive_ptr; /////////////////////////////////////////////////////////////////////////// // content_merge_database_adaptor @@ -104,17 +105,17 @@ content_merge_database_adaptor::cache_ro void content_merge_database_adaptor::cache_roster(revision_id const & rid, - boost::shared_ptr roster) + boost::intrusive_ptr roster) { safe_insert(rosters, make_pair(rid, roster)); }; static void load_and_cache_roster(database & db, revision_id const & rid, - map > & rmap, - shared_ptr & rout) + map > & rmap, + intrusive_ptr & rout) { - map >::const_iterator i = rmap.find(rid); + map >::const_iterator i = rmap.find(rid); if (i != rmap.end()) rout = i->second; else @@ -129,7 +130,7 @@ content_merge_database_adaptor::get_ance void content_merge_database_adaptor::get_ancestral_roster(node_id nid, revision_id & rid, - shared_ptr & anc) + intrusive_ptr & anc) { // Given a file, if the lca is nonzero and its roster contains the file, // then we use its roster. Otherwise we use the roster at the file's @@ -185,7 +186,7 @@ content_merge_workspace_adaptor::cache_r void content_merge_workspace_adaptor::cache_roster(revision_id const & rid, - boost::shared_ptr roster) + boost::intrusive_ptr roster) { rosters.insert(std::make_pair(rid, roster)); } @@ -226,7 +227,7 @@ content_merge_workspace_adaptor::get_anc void content_merge_workspace_adaptor::get_ancestral_roster(node_id nid, revision_id & rid, - shared_ptr & anc) + intrusive_ptr & anc) { // Begin by loading any non-empty file lca roster if (base->has_node(nid)) @@ -321,7 +322,7 @@ content_merge_checkout_adaptor::get_ance void content_merge_checkout_adaptor::get_ancestral_roster(node_id nid, revision_id & rid, - shared_ptr & anc) + intrusive_ptr & anc) { I(false); } @@ -360,7 +361,7 @@ content_merge_empty_adaptor::get_ancestr void content_merge_empty_adaptor::get_ancestral_roster(node_id nid, revision_id & rid, - shared_ptr & anc) + intrusive_ptr & anc) { I(false); } @@ -586,7 +587,7 @@ try_to_merge_files(lua_hooks & lua, MM(conflict); revision_id rid; - shared_ptr roster_for_file_lca; + intrusive_ptr roster_for_file_lca; adaptor.get_ancestral_roster(conflict.nid, rid, roster_for_file_lca); // Now we should certainly have a roster, which has the node. ============================================================ --- merge_content.hh f686979a4a2f6af3912880b91d8c9fea3be2db06 +++ merge_content.hh 3d5fc9049a8b0ad4843be89c462b70cc979c43bf @@ -13,6 +13,7 @@ #include "vocab.hh" #include "rev_types.hh" +#include "roster.hh" #include "paths.hh" class database; @@ -38,7 +39,7 @@ content_merge_adaptor virtual void get_ancestral_roster(node_id nid, revision_id & rid, - boost::shared_ptr & anc) = 0; + boost::intrusive_ptr & anc) = 0; virtual void get_version(file_id const & ident, file_data & dat) const = 0; @@ -56,7 +57,7 @@ content_merge_database_adaptor revision_id right_rid; marking_map const & left_mm; marking_map const & right_mm; - std::map > rosters; + std::map > rosters; content_merge_database_adaptor(database & db, revision_id const & left, revision_id const & right, @@ -75,11 +76,11 @@ content_merge_database_adaptor file_data const & merged_data); void cache_roster(revision_id const & rid, - boost::shared_ptr roster); + boost::intrusive_ptr roster); void get_ancestral_roster(node_id nid, revision_id & rid, - boost::shared_ptr & anc); + boost::intrusive_ptr & anc); void get_version(file_id const & ident, file_data & dat) const; @@ -92,14 +93,14 @@ content_merge_workspace_adaptor std::map temporary_store; database & db; revision_id const lca; - boost::shared_ptr base; + boost::intrusive_ptr base; marking_map const & left_mm; marking_map const & right_mm; - std::map > rosters; + std::map > rosters; std::map content_paths; content_merge_workspace_adaptor(database & db, revision_id const & lca, - boost::shared_ptr base, + boost::intrusive_ptr base, marking_map const & left_mm, marking_map const & right_mm, std::map const & paths) @@ -108,7 +109,7 @@ content_merge_workspace_adaptor {} void cache_roster(revision_id const & rid, - boost::shared_ptr roster); + boost::intrusive_ptr roster); void record_merge(file_id const & left_ident, file_id const & right_ident, @@ -124,7 +125,7 @@ content_merge_workspace_adaptor void get_ancestral_roster(node_id nid, revision_id & rid, - boost::shared_ptr & anc); + boost::intrusive_ptr & anc); void get_version(file_id const & ident, file_data & dat) const; @@ -153,7 +154,7 @@ content_merge_checkout_adaptor void get_ancestral_roster(node_id nid, revision_id & rid, - boost::shared_ptr & anc); + boost::intrusive_ptr & anc); void get_version(file_id const & ident, file_data & dat) const; @@ -179,7 +180,7 @@ content_merge_empty_adaptor void get_ancestral_roster(node_id nid, revision_id & rid, - boost::shared_ptr & anc); + boost::intrusive_ptr & anc); void get_version(file_id const & ident, file_data & dat) const; ============================================================ --- merge_roster.hh c721929e38b641375ea2b5ac1ae2fdd081e88882 +++ merge_roster.hh 72c9ecaadb606f9d6a7bb6d0df2b057f0f366115 @@ -264,9 +264,9 @@ struct roster_merge_result revision_id const & ancestor_rid, revision_id const & left_rid, revision_id const & right_rid, - boost::shared_ptr left_roster, + boost::intrusive_ptr left_roster, marking_map const & left_marking, - boost::shared_ptr right_roster, + boost::intrusive_ptr right_roster, marking_map const & right_marking); }; ============================================================ --- migrate_ancestry.cc c02341580f9e65387807dc8f1ae3874d26e81198 +++ migrate_ancestry.cc 7b271fb749e27230558554db15961ab9ca9900ee @@ -40,11 +40,12 @@ using boost::shared_ptr; using std::string; using std::vector; using boost::shared_ptr; +using boost::intrusive_ptr; // Stuff related to rebuilding the revision graph. Unfortunately this is a // real enough error case that we need support code for it. -typedef map, shared_ptr > > +typedef map, shared_ptr > > parent_roster_map; template <> void @@ -430,7 +431,7 @@ not_dead_yet(node_id nid, u64 birth_rev, for (parent_roster_map::const_iterator r = parent_rosters.begin(); r != parent_rosters.end(); ++r) { - shared_ptr parent = r->second.first; + intrusive_ptr parent = r->second.first; // L(FL("node %d %s in parent roster %d") // % nid // % (parent->has_node(n->first) ? "exists" : "does not exist" ) @@ -539,7 +540,7 @@ anc_graph::fixup_node_identities(parent_ for (parent_roster_map::const_iterator i = parent_rosters.begin(); i != parent_rosters.end(); ++i) { - shared_ptr parent_roster = i->second.first; + intrusive_ptr parent_roster = i->second.first; shared_ptr parent_marking = i->second.second; node_map const & nodes = parent_roster->all_nodes(); @@ -573,7 +574,7 @@ anc_graph::fixup_node_identities(parent_ for (parent_roster_map::const_iterator j = parent_rosters.begin(); j != parent_rosters.end(); ++j) { - shared_ptr parent_roster = j->second.first; + intrusive_ptr parent_roster = j->second.first; if (!parent_roster->has_node(n)) continue; @@ -727,7 +728,7 @@ anc_graph::construct_revisions_from_ance u64 parent = i->second; if (parent_rosters.find(parent) == parent_rosters.end()) { - shared_ptr ros = shared_ptr(new roster_t()); + intrusive_ptr ros = intrusive_ptr(new roster_t()); shared_ptr mm = shared_ptr(new marking_map()); db.get_roster(safe_get(node_to_new_rev, parent), *ros, *mm); safe_insert(parent_rosters, make_pair(parent, make_pair(ros, mm))); @@ -822,7 +823,7 @@ anc_graph::construct_revisions_from_ance { u64 parent = i->first; revision_id parent_rid = safe_get(node_to_new_rev, parent); - shared_ptr parent_roster = i->second.first; + intrusive_ptr parent_roster = i->second.first; shared_ptr cs = shared_ptr(new cset()); MM(*cs); make_cset(*parent_roster, child_roster, *cs); @@ -837,7 +838,7 @@ anc_graph::construct_revisions_from_ance if (rev.edges.empty()) { revision_id parent_rid; - shared_ptr parent_roster = shared_ptr(new roster_t()); + intrusive_ptr parent_roster = intrusive_ptr(new roster_t()); shared_ptr cs = shared_ptr(new cset()); MM(*cs); make_cset(*parent_roster, child_roster, *cs); ============================================================ --- restrictions.hh cbbc558507e794f658622f153ebda63b1b5ea039 +++ restrictions.hh 1614d7a25729db50e506527ee1d3889e76006003 @@ -31,6 +31,7 @@ #include #include "vocab.hh" #include "rev_types.hh" +#include "roster.hh" #include "paths.hh" // between any two related revisions, A and B, there is a set of changes (a ============================================================ --- rev_types.hh 57f8ea1d809f63101811a9c816f413b3fa912872 +++ rev_types.hh af6493b1e40fbc2ef447aad689a5203747b23a7b @@ -89,13 +89,6 @@ class transaction_guard; class conditional_transaction_guard; class transaction_guard; -typedef boost::shared_ptr roster_t_cp; -typedef boost::shared_ptr marking_map_cp; -typedef std::pair cached_roster; - -typedef std::map parent_map; -typedef parent_map::value_type parent_entry; - #endif // __REV_TYPES_HH__ // Local Variables: ============================================================ --- revision.hh 75bac531320de250cc7d0660762c3b01e04147dd +++ revision.hh 8a319bd419729009989da49fdf0d1042981b6888 @@ -13,6 +13,7 @@ #include #include "vector.hh" #include "rev_types.hh" +#include "roster.hh" // need parent_map class key_store; class node_restriction; @@ -150,7 +151,7 @@ ancestry_difference(database & db, revis // FIXME: can probably optimize this passing a lookaside cache of the active -// frontier set of shared_ptrs, while traversing history. +// frontier set of intrusive_ptrs, while traversing history. void select_nodes_modified_by_rev(database & db, revision_t const & rev, ============================================================ --- roster.hh f79fe7c3e150abe91f2497421a71eacbd0145d60 +++ roster.hh 52c178b2e61e71b366d6d0300f02c3fe8e09d24f @@ -15,6 +15,7 @@ #include "paths.hh" #include "rev_types.hh" #include "cset.hh" // need full definition of editable_tree +#include "intrusive_ptr.hh" struct node_id_source { @@ -148,7 +149,7 @@ template <> void dump(marking_map const template <> void dump(marking_t const & marking, std::string & out); template <> void dump(marking_map const & marking_map, std::string & out); -class roster_t +class roster_t : public intrusively_refcounted { public: roster_t() {} @@ -309,7 +310,13 @@ protected: node_id_source & nis; }; +typedef boost::intrusive_ptr roster_t_cp; +typedef boost::shared_ptr marking_map_cp; +typedef std::pair cached_roster; +typedef std::map parent_map; +typedef parent_map::value_type parent_entry; + void make_cset(roster_t const & from, roster_t const & to, ============================================================ --- work.cc 766cbbfd5b78c442ed6fc650846daa55f9d42768 +++ work.cc fd3ac41716a28199abc492b669bfff5550ece406 @@ -278,7 +278,7 @@ get_roster_for_rid(database & db, // roster (and marking map). if (null_id(rid)) { - cr.first = boost::shared_ptr(new roster_t); + cr.first = boost::intrusive_ptr(new roster_t); cr.second = boost::shared_ptr(new marking_map); } else ============================================================ --- work.hh d6167a82e9e8fefa17d892c09af2ed0c78f8ded5 +++ work.hh 0282f5fd5c21280eeab004179aaba984ecfc09d8 @@ -13,6 +13,7 @@ #include #include "paths.hh" #include "rev_types.hh" +#include "roster.hh" class path_restriction; class node_restriction;