Ejemplo n.º 1
0
void unit_map::swap(unit_map &o) {
	assert(num_iters()==0 && o.num_iters() == 0);

	std::swap(umap_, o.umap_);
	std::swap(lmap_, o.lmap_);
	std::swap(ilist_, o.ilist_);
	std::swap(the_end_, o.the_end_);
}
Ejemplo n.º 2
0
size_t unit_map::num_iters() const  {
	///Add up number of extant iterators
	size_t num_iters(0);
	t_ilist::const_iterator ii(ilist_.begin());
	for( ; ii != the_end_ ; ++ii){
		if(ii->ref_count < 0) {
			//Somewhere, someone generated 2^31 iterators to this unit
			bool a_reference_counter_overflowed(false);
			assert(a_reference_counter_overflowed); }
		num_iters += ii->ref_count; }

	return num_iters;
}
Ejemplo n.º 3
0
void unit_map::clear(bool force) {
	assert(force  || (num_iters() == 0));

	for (t_umap::iterator i = umap_.begin(); i != umap_.end(); ++i) {
		if (is_valid(i)) {
			DBG_NG << "Delete unit " << i->second.unit->underlying_id() << "\n";
			i->second.unit.reset();
		}
	}

	lmap_.clear();
	umap_.clear();
}
Ejemplo n.º 4
0
void unit_map::clear(bool force) {
	assert(force  || (num_iters() == 0));

	for (t_ilist::iterator i = ilist_.begin(); i != the_end_; ++i) {
		if (is_valid(i)) {
			DBG_NG << "Delete unit " << i->unit->underlying_id() << "\n";
			delete i->unit;
		}
	}

	lmap_.clear();
	umap_.clear();
	ilist_.clear();
}
Ejemplo n.º 5
0
size_t unit_map::num_iters() const  {
	///Add up number of extant iterators
	size_t num_iters(0);
	t_umap::const_iterator ui = umap_.begin();
	t_umap::const_iterator uend = umap_.end();
	for( ; ui != uend ; ++ui){
		if(ui->second.ref_count < 0) {
			//Somewhere, someone generated 2^31 iterators to this unit
			bool a_reference_counter_overflowed(false);
			assert(a_reference_counter_overflowed);
		}
		num_iters += ui->second.ref_count;
	}

	return num_iters;
}
Ejemplo n.º 6
0
void unit_map::swap(unit_map &o) {
	assert(num_iters()==0 && o.num_iters() == 0);

	std::swap(umap_, o.umap_);
	std::swap(lmap_, o.lmap_);
}