Issue #251 CkLocMgr: Add a destructor
authorPhil Miller <mille121@illinois.edu>
Thu, 8 Aug 2013 20:33:40 +0000 (15:33 -0500)
committerPhil Miller <mille121@illinois.edu>
Tue, 20 Aug 2013 23:17:37 +0000 (18:17 -0500)
src/ck-core/cklocation.C
src/ck-core/cklocation.h

index a8f487c28c826f8df78b18d85581a45d4b5c9dec..0a350c51ea32d0ec9762f0cd6e131a43c6d9202a 100644 (file)
@@ -2094,7 +2094,7 @@ CkLocMgr::CkLocMgr(CkArrayOptions opts)
        duringMigration=false;
        nSprings=0;
 #if !CMK_GLOBAL_LOCATION_UPDATE
-       CcdCallOnConditionKeepOnPE(CcdPERIODIC_1minute,staticSpringCleaning,(void *)this, CkMyPe());
+       springCleaningCcd = CcdCallOnConditionKeepOnPE(CcdPERIODIC_1minute,staticSpringCleaning,(void *)this, CkMyPe());
 #endif
 
 //Register with the map object
@@ -2125,11 +2125,22 @@ CkLocMgr::CkLocMgr(CkMigrateMessage* m)
        duringMigration=false;
        nSprings=0;
 #if !CMK_GLOBAL_LOCATION_UPDATE
-       CcdCallOnConditionKeepOnPE(CcdPERIODIC_1minute,staticSpringCleaning,(void *)this, CkMyPe());
+       springCleaningCcd = CcdCallOnConditionKeepOnPE(CcdPERIODIC_1minute,staticSpringCleaning,(void *)this, CkMyPe());
 #endif
        hashImmLock = CmiCreateImmediateLock();
 }
 
+CkLocMgr::~CkLocMgr() {
+#if CMK_LBDB_ON
+  the_lbdb->RemoveLocalBarrierClient(dummyBarrierHandle);
+  the_lbdb->RemoveLocalBarrierReceiver(lbBarrierReceiver);
+  the_lbdb->UnregisterOM(myLBHandle);
+#endif
+  CcdCancelCallOnConditionKeep(CcdPERIODIC_1minute, springCleaningCcd);
+  map->unregisterArray(mapHandle);
+  CmiDestroyLock(hashImmLock);
+}
+
 void CkLocMgr::pup(PUP::er &p){
        IrrGroup::pup(p);
        p|mapID;
@@ -3334,7 +3345,7 @@ void CkLocMgr::initLB(CkGroupID lbdbID_, CkGroupID metalbID_)
          us to call Registering/DoneRegistering during each AtSync,
          and this is the only way to do so.
        */
-       the_lbdb->AddLocalBarrierReceiver(
+       lbBarrierReceiver = the_lbdb->AddLocalBarrierReceiver(
                (LDBarrierFn)staticRecvAtSync,(void*)(this));
        dummyBarrierHandle = the_lbdb->AddLocalBarrierClient(
                (LDResumeFn)staticDummyResumeFromSync,(void*)(this));
index a1d178ccbc435e85f7a658aa8f87aa0df7b16217..151cb11fd3daf2d32b645211a246fd515b32f900 100644 (file)
@@ -286,6 +286,7 @@ class CkLocMgr : public IrrGroup {
 public:
        CkLocMgr(CkArrayOptions opts);
        CkLocMgr(CkMigrateMessage *m);
+        ~CkLocMgr();
 
        inline bool isLocMgr(void) { return true; }
        CkGroupID &getGroupID(void) {return thisgroup;}
@@ -499,6 +500,7 @@ public:
        static void staticSpringCleaning(void *mgr,double curWallTime);
        void springCleaning(void);
        int nSprings;
+       int springCleaningCcd;
 
 private:
        //Map object
@@ -524,6 +526,7 @@ private:
        static void staticRecvAtSync(void* data);
        void recvAtSync(void);
        LDOMHandle myLBHandle;
+        LDBarrierReceiver lbBarrierReceiver;
 #endif
 private:
        void initLB(CkGroupID lbdbID, CkGroupID metalbID);