zend_list_addref() / zend_list_delete() question.
| From: | Thies C. Arntzen | Date: | Thu, 30 Sep 1999 09:06:58 +0000 |
| Subject: | zend_list_addref() / zend_list_delete() question. | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-5023@lists.php.net to get a copy of this message | ||
hi,
been playing with the refcount stuff - works GREAT!
question:
can i call zend_list_delete() from a destructor function? - it would be
great if we could implement resource-dependicies that way!
sample shows how we can make sure that the db-connection gets closed
*AFTER* all cursors!
BTW: i think it would be nice to have a zend_list_delref(id)
function/macro.
i think that would be a huge step for the more complex modules!
regards,
tc
pseudo-code:
conn_dtor(conn)
{ db_close(conn);
}
cursor_dtor(cursor)
{ close_db_cursor(cursor);
zend_list_delete(cursor.conn); // zend_list_delref(cursor.conn);
}
logon()
{ conn = logon_to_db();
register_resource(conn);
return conn;
}
open_cursor(conn)
{ cursor.cursor = open_db_cursor(conn);
cursor.conn = conn;
zend_list_addref(cursor.conn);
register_resource(cursor);
return cursor;
}