ObjectDesc *copy_memory(DomainDesc * src, DomainDesc * dst, struct MemoryProxy_s *obj, u4_t * quota) { if (obj == NULL) return NULL; if (src == dst) return obj; if (src == domainZero) { MemoryProxyHandle handle = allocMemoryProxyInDomain(dst, obj2ClassDesc(obj), obj->mem, obj->size); ObjectDesc *o = unregisterObject(dst, handle); //printf("MEMADDR2: %p\n", o); addToRefTable(obj, o); return (ObjectDesc *) o; } #ifdef ALLOW_SHARING { MemoryProxyHandle handle = allocMemoryProxyInDomain(dst, obj2ClassDesc(obj), obj->mem, obj->size); ObjectDesc *o = unregisterObject(dst, handle); //printf("MEMADDR2: %p\n", o); addToRefTable(obj, o); return (ObjectDesc *) o; } #else exceptionHandlerMsg(THROW_RuntimeException, "Memory objects cannot be copied between domains in the current configuration"); #endif }
GrObjectCache::~GrObjectCache() { // Some GrObjects may be in flight but someone destroys the cache. Do a manual destruction of the map for(auto it : m_map) { GrObject* ptr = it; unregisterObject(ptr); } }
void SFX3DWorld::notifyChanged( SceneObject* object ) { SFX3DObject* sfxObject = dynamic_cast< SFX3DObject* >( SFX3DObject::getLinkForTracker( this, object ) ); if( !sfxObject && _isTrackableObject( object ) ) registerObject( object ); else if( sfxObject && !_isTrackableObject( object ) ) unregisterObject( object ); else if( sfxObject ) mSFXWorld.notifyChanged( sfxObject ); }
void GateObject::isWalked( int __idAgent ) { // if ( gVerbose && gDisplayMode <= 1) // std::cout << "[DEBUG] Physical object #" << this->getId() << " (gate) walked upon by robot #" << __idAgent << std::endl; unregisterObject(); hide(); _visible = false; regrow = true; regrowTime = regrowTimeMax; }
/** Set object state. @param state_new new object state @return old object state */ state_t setState(state_t state_new) { state_t state_old = getState(); if(state_new == state_old) return state_old; switch(state_old) { case STATE_UNUSED: { registerObject(); setState(state_new); break; } case STATE_GRAPHICS_BOUND: { unbindObject(); setState(state_new); break; } case STATE_INACTIVE: { switch(state_new) { case STATE_UNUSED: unregisterObject(); break; case STATE_GRAPHICS_BOUND: bindObject(); break; case STATE_CUDA_MAPPED: mapObject(); break; case STATE_INACTIVE: // avoid warning message break; } break; } case STATE_CUDA_MAPPED: { unmapObject(); setState(state_new); } } return state_old; }
void SwitchObject::isWalked( int __idAgent ) { // if ( gVerbose && gDisplayMode <= 1) // std::cout << "[DEBUG] Physical object #" << this->getId() << " (switch) walked upon by robot #" << __idAgent << std::endl; if ( (size_t)sendMessageTo < gPhysicalObjects.size() ) gPhysicalObjects[sendMessageTo]->isWalked(-1); unregisterObject(); hide(); _visible = false; regrow = true; regrowTime = regrowTimeMax; }
AbstractDBusInterface::~AbstractDBusInterface() { unregisterObject(); PropertyList impl = implementedProperties(); for(auto itr = impl.begin(); itr != impl.end(); itr++) { if(properties.find(*itr) != properties.end()) { // Deleted in ~DBusSink() //delete properties[*itr]; properties.erase(*itr); } } objectMap.erase(mObjectPath); }
DerpVM::~DerpVM(void) { // This will clean up global state except for things where // something still holds a reference. globalContext.clearAllVariables(); garbageCollect(); // Destroy all objects that have no external references. // Orphan everything else. while(gcObjects.size()) { if(gcObjects[0]->externalRefCount > 1) { unregisterObject(gcObjects[0]); } else { delete gcObjects[0]; } } }
int mainMenu(void) { int option = -1; //system("clear"); printf("Welcome\n"); printf("1. Register\n"); printf("2. Unregister\n"); printf("3. Query\n"); printf("4. Exit\n"); printf("\nOption: "); scanf("%d", &option); switch (option) { case 1: registerObject(); break; case 2: unregisterObject(); break; case 3: query(); break; case 4: printf("All done!\n"); break; default: // no point printing message; system("clear") will erase it. //printf("Enter a valid Option, 1 - 4"); // this will flush the input stream while (getchar() != '\n'); break; } return option; }
InputObject::~InputObject() { unregisterObject(this) ; }
void NotifyObserver::unregisterPrefix(const string& command, BaseNotify* obj) { unregisterObject(command, obj, _prefix); }
void NotifyObserver::unregisterNotify(const string& command, BaseNotify* obj) { unregisterObject(command, obj, _notifys); }
void DerpVM::garbageCollect(void) { if(gcObjects.size() > maxVmObs) { maxVmObs = gcObjects.size(); } // Do something about reference counts on tables, otherwise // circular references will own us. addTableRefs(-1); lastGCPass++; // Mark all objects with external references, and all // functions will positive call counts. for(unsigned int i = 0; i < gcObjects.size(); i++) { if(gcObjects[i]->externalRefCount > 1 || !gcObjects[i]->getGarbageCollectible()) { // Object has external references or is not GCable. // Mark it. gcObjects[i]->markGCPass(lastGCPass); } else if(gcObjects[i]->type == DERPTYPE_FUNCTION) { if(gcObjects[i]->functionData.callCounter) { // Function is in the callstack. Mark it as in // use. gcObjects[i]->markGCPass(lastGCPass); } } } vector<DerpObject*> obsToKill; vector<DerpObject*> obsToDelete; // Clean out anything that didn't make the cut. for(unsigned int i = 0; i < gcObjects.size(); i++) { if(gcObjects[i]->getGarbageCollectible()) { if(gcObjects[i]->lastGCPass != lastGCPass) { // Didn't get hit on the last garbage collection pass. // Add it to the list of stuff to clean up. obsToKill.push_back(gcObjects[i]); if(gcObjects[i]->externalRefCount == 1) { // This object will have to be manually deleted by // us because the only reference it has is the // fake one the VM adds. obsToDelete.push_back(gcObjects[i]); } } } } // Restore table ref counts. addTableRefs(1); // Complicated method to clean up data. First, we're going to // hold references to everything that we want to delete to // tmpRefs. Then we're going to unregister them all from the // VM. Then we'll call clearData on each of them to "unstick" // them from each other (they won't have refs to each other // that'll cause some to be destroyed leaving a dangling // pointer int the list of stuff to destroy). After that, the // only reference to each object will be in the tmpRefs, and // they'll be independent. Letting tmpRefs get cleared will // release all those references. // Hold references for everything we want to delete. vector<DerpObject::Ref> tmpRefs; for(unsigned int i = 0; i < obsToDelete.size(); i++) { tmpRefs.push_back(obsToDelete[i]); } // Unregister everything that didn't get touched by the // garbage collector. Will not trigger auto destruction for // last reference because we hold tmpRefs. for(unsigned int i = 0; i < obsToKill.size(); i++) { DerpObject *ob = obsToKill[i]; unregisterObject(ob); } // Unstick all the to-be-deleted data. for(unsigned int i = 0; i < obsToDelete.size(); i++) { obsToDelete[i]->clearData(); } // Nuke the now independent data. tmpRefs.clear(); }
void AbstractDBusInterface::startRegistration() { unregisterObject(); introspectionXml ="<node>" ; introspectionXml += "<interface name='"+ mInterfaceName + "' >"; }