Exemple #1
0
int Database::save_obj(Object * & obj)
{
    
    string key = wstring_to_string(obj->name);
    Json::Value attrs;
    ObjMapMap::iterator it = obj->attr_maps.begin();
    for (; it != obj->attr_maps.end(); it++){
        ObjMap * map = it->second;
        string map_name = it->first;
        ObjMap::iterator i = map->begin();
        attrs[map_name] = Json::nullValue;
        for (; i != map->end(); i++){
            attrs[map_name].append(wstring_to_string(i->first));
        }
        
    }
    root[key] = attrs;
    return 0;
}
void PyAtom::Collect()
{
    for(;;) {
        ObjMap::iterator it = objmap.begin();
        if(it == objmap.end() || it->first > collix) break;
        
        PyObject *obj = it->second;
        Py_DECREF(obj);
        objmap.erase(it);

#ifdef _DEBUG
//        post("DEL %p\n",obj);
#endif
    }

    // schedule next collect time
    double tm = flext::GetTime();
    if(tm > last+INTV) last = tm,collix = curix;
}