PNS_NODE::~PNS_NODE()
{
    TRACE( 0, "PNS_NODE::delete %p", this );

    if( !m_children.empty() )
    {
        TRACEn( 0, "attempting to free a node that has kids.\n" );
        assert( false );
    }

#ifdef DEBUG
    if( allocNodes.find( this ) == allocNodes.end() )
    {
        TRACEn( 0, "attempting to free an already-free'd node.\n" );
        assert( false );
    }

    allocNodes.erase( this );
#endif

    for( PNS_INDEX::ITEM_SET::iterator i = m_index->begin(); i != m_index->end(); ++i )
    {
        if( (*i)->BelongsTo( this ) )
            delete *i;
    }


    releaseGarbage();
    unlinkParent();

    delete m_index;
}
Beispiel #2
0
    inline Size Observable::unregisterObserver(Observer* o) {
    	// in case the observer is in the deferred notifications list
    	// remove it
        if (settings_.updatesDeferred())
    	    settings_.unregisterDeferredObserver(o);

    	return observers_.erase(o);
    }
Beispiel #3
0
bool WRLDRecord::deep_equals(Record *master, RecordOp &read_self, RecordOp &read_master, boost::unordered_set<Record *> &identical_records)
    {
    //Precondition: equals has been run for these records and returned true
    //              all child records have been visited
    const WRLDRecord *master_wrld = (WRLDRecord *)master;

    if(CELLS.size() > master_wrld->CELLS.size())
        return false;

    if(ROAD != NULL)
        {
        if(master_wrld->ROAD != NULL)
            {
            if(identical_records.count(ROAD) == 0)
                return false;
            }
        else
            return false;
        }

    if(CELL != NULL)
        {
        if(master_wrld->CELL != NULL)
            {
            if(identical_records.count(CELL) == 0)
                return false;
            }
        else
            return false;
        }

    for(uint32_t ListIndex = 0; ListIndex < CELLS.size(); ++ListIndex)
        if(identical_records.count(CELLS[ListIndex]) == 0)
                return false;

    //The cell and all its contents are dupes, so remove the child records from identical_records
    // This prevents Bash from trying to double delete records (first the cell, and later a child that was in the cell)
    identical_records.erase(ROAD);
    identical_records.erase(CELL);

    for(uint32_t ListIndex = 0; ListIndex < CELLS.size(); ++ListIndex)
        identical_records.erase(CELLS[ListIndex]);
    return true;
    }
void sanity_checks() {
 ASSERT_TRUE(cm.begin() == cm.end());

  for (size_t i = 0;i < NINS; ++i) {
    um.insert(17 * i);
  }
  
  graphlab::thread_group thrgroup;
  for (size_t i = 0; i < 10; ++i) {
    thrgroup.launch(boost::bind(parallel_inserter, 
                                i * NINS/10, 
                                (i + 1) * NINS / 10));

  }

  thrgroup.join();
   
  std::cout << "Size: " << cm.size() << std::endl;
  std::cout << "Capacity: " << cm.capacity() << std::endl;
  std::cout << "Load Factor: " << cm.load_factor() << std::endl;

  for (size_t i = 0;i < NINS; ++i) {
    if (cm.get_sync(17 * i).first == false) {
      std::cout << cm.count(17 * i) << "\n";
      std::cout << "Failure on: " << 17 * i << std::endl;
      assert(cm.get_sync(17 * i).first == true);
    }
    assert(um.count(17 * i) == 1);
  }
  assert(cm.size() == NINS);
  assert(um.size() == NINS);

  for (size_t i = 0;i < NINS; i+=2) {
    um.erase(17*i);
  }

  for (size_t i = 0; i < 10; ++i) {
    thrgroup.launch(boost::bind(parallel_erase, 
                                i * NINS/10, 
                                (i + 1) * NINS / 10));
  }

  thrgroup.join();
   

  for (size_t i = 0;i < NINS; i+=2) {
    assert(cm.get_sync(17*i).first == (bool)(i % 2));
    assert(um.count(17*i) == i % 2);
  }

  assert(cm.size() == NINS / 2);
  assert(um.size() == NINS / 2);
} 
Beispiel #5
0
PNS_NODE::~PNS_NODE()
{
    if( !m_children.empty() )
    {
        TRACEn( 0, "attempting to free a node that has kids.\n" );
        assert( false );
    }

    if( allocNodes.find( this ) == allocNodes.end() )
    {
        TRACEn( 0, "attempting to free an already-free'd node.\n" );
        assert( false );
    }

    allocNodes.erase( this );

    for( PNS_INDEX::ItemSet::iterator i = m_index->begin();
         i != m_index->end(); ++i )
        if( (*i)->BelongsTo( this ) )
            delete *i;

    unlinkParent();
    delete m_index;
}
Beispiel #6
0
    inline Size Observable::unregisterObserver(Observer* o) {
        if (settings_.updatesDeferred())
            settings_.unregisterDeferredObserver(o);

        return observers_.erase(o);
    }
Beispiel #7
0
void Object::remove_live_object(Object* o) {
  IMP_INTERNAL_CHECK(live_.find(o) != live_.end(),
                     "Object " << o->get_name() << " not found in live list.");
  live_.erase(o);
}
Beispiel #8
0
 inline
 Size Observer::unregisterWith(const boost::shared_ptr<Observable>& h) {
     if (h)
         h->unregisterObserver(this);
     return observables_.erase(h);
 }
Beispiel #9
0
    inline void ObservableSettings::unregisterDeferredObserver(Observer* o) {
	QL_TRACE("removing observer " << o << " from the deferred list");
    	deferredObservers_.erase(o);
    }