File: DeleteLater.cpp

package info (click to toggle)
eris 1.3.10-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 2,592 kB
  • ctags: 1,516
  • sloc: cpp: 9,850; sh: 8,288; perl: 287; ansic: 165; makefile: 162
file content (31 lines) | stat: -rw-r--r-- 705 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <Eris/DeleteLater.h>
#include <vector>

namespace Eris
{

static std::vector<BaseDeleteLater*> global_deleteLaterQueue;

BaseDeleteLater::~BaseDeleteLater()
{
}

void pushDeleteLater(BaseDeleteLater* bl)
{
    global_deleteLaterQueue.push_back(bl);
}

void execDeleteLaters()
{
    while (!global_deleteLaterQueue.empty()) {
        // ordering here is important, in cases where deleting 'foo' causes
        // other objects to be 'deleteLater'ed; we want to clean them up in
        // this same cycle, not leave the hanging around.
        
        BaseDeleteLater* dl = global_deleteLaterQueue.back();
        global_deleteLaterQueue.pop_back();
        delete dl;
    }
}

} // of namespace