Life time management
Firebird interfaces are not based on the COM specification, sotheir lifetime is managed differently.
There are two interfaces in Firebird that deal with lifetime management:IDisposable
and IReferenceCounted
. The latter is especially active whencreating other interfaces: IPlugin
counts links, like many other interfacesused by plug-ins. These include interfaces that describe the databaseconnection, transaction management, and SQL statements.
You don’t always need the extra overhead of a reference-counted interface. Forexample, IMaster
, the main interface that calls functions available to therest of the API, has an unlimited lifetime by definition. For other APIs, thelifetime is strictly determined by the lifetime of the parent interface;interface ISatus
is notmultithreaded. For interfaces with limited lifetimes, it is useful to have aneasy way to destroy them, i.e. the dispose()
function.
Tip
|
Clue
If you don’t know how an object is destroyed, look up its hierarchy if it hasthe |
Some methods of interfaces derived from IReferenceCounted
release the interfaceafter successful completion. There is no need to call release()
after calling such methods.
This is done for historical reasons, because similar functions from the ISC API freed the corresponding handle.
Here is a list of such methods:
-
IAttachment
interface-
detach(status: IStatus)
- disconnect the connection to the database. On success, releases the interface. -
dropDatabase(status: IStatus)
- drop database. On success, releases the interface.
-
-
Interface
ITransaction
-
commit(status: IStatus)
- transaction confirmation. On success, releases the interface. -
rollback(status: IStatus)
- transaction rollback. On success, releases the interface.
-
-
IStation
interface-
free(status: IStatus)
- removes a prepared statement. On success, releases the interface.
-
-
IResultSet
interface-
close(status: IStatus)
closes the cursor. On success, releases the interface.
-
-
IBlob
interface-
cancel(status: IStatus)
- cancels all changes made to the temporary BLOB (if any) and closes the BLOB. On success, releases the interface. -
close(status: IStatus)
- saves all changes made to the temporary BLOB (if any) and closes the BLOB. On success, releases the interface.
-
-
Interface
IService
-
detach(status: IStatus)
- disconnect the connection with the service manager. On success, releases the interface.
-
-
IEvents
interface-
cancel(status: IStatus)
- cancels event subscription. On success, releases the interface.
-