F #4936: Refactor pools to use unique_ptr

co-authored-by: Pavel Czerný <pczerny@opennebula.systems>
This commit is contained in:
Ruben S. MonteroandPavel Czerný committed 2020-09-10 09:08:29 +02:00
1 parent ef17f77d26
commit 5ce49ed404
124 files changed
+3676 -5179

No files matched your search

-91
View File
@@ -165,66 +165,6 @@ int PoolSQL::allocate(PoolObjectSQL *objsql, string& error_str)
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
PoolObjectSQL * PoolSQL::get(int oid)
{
if ( oid < 0 )
{
return 0;
}
pthread_mutex_t * object_lock = cache.lock_line(oid);
PoolObjectSQL * objectsql = create();
objectsql->oid = oid;
objectsql->ro = false;
objectsql->mutex = object_lock;
int rc = objectsql->select(db);
if ( rc != 0 )
{
objectsql->unlock(); //Free object and unlock cache line mutex
return 0;
}
return objectsql;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
PoolObjectSQL * PoolSQL::get_ro(int oid)
{
if ( oid < 0 )
{
return 0;
}
PoolObjectSQL * objectsql = create();
objectsql->oid = oid;
objectsql->ro = true;
int rc = objectsql->select(db);
if ( rc != 0 )
{
objectsql->unlock(); //Free object;
return 0;
}
return objectsql;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void PoolSQL::exist(const string& id_str, std::set<int>& id_list)
{
std::vector<int> existing_items;
@@ -245,37 +185,6 @@ void PoolSQL::exist(const string& id_str, std::set<int>& id_list)
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
PoolObjectSQL * PoolSQL::get(const string& name, int ouid)
{
int oid = PoolObjectSQL::select_oid(db, table.c_str(), name, ouid);
if ( oid == -1 )
{
return 0;
}
return get(oid);
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
PoolObjectSQL * PoolSQL::get_ro(const string& name, int uid)
{
int oid = PoolObjectSQL::select_oid(db, table.c_str(), name, uid);
if ( oid == -1 )
{
return 0;
}
return get_ro(oid);
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
int PoolSQL::dump(string& oss, const string& elem_name, const string& column,
const char* table, const string& where, int sid, int eid, bool desc)
{