Subject RE: [IB-Architect] New API: Object Life Time
Author Jim Starkey
At 01:20 AM 6/2/00 -0400, Claudio Valderrama C. wrote:
>>
>> Object life times are managed with addRef() and release(). When
>> the use count (decremented by release()) goes to zero, the object
>> joins the great bit bucket in the sky.
>
>
> Seem fine and you can do whatever you want in the implementation. Trying to
>avoid delete operator?
>

I've made all destructors protected to make explicit deletion
illegal. Everything is now released.

>
>> The method close(), when present, can be used to release any context
>> or resources associated with the object but without deleting the
>> object.
>
>
> As long as it has some coherency with the specification you are trying to
>follow, it seems acceptable. However, the term "context or resources" is a
>bit blurry for me. What would be left after a close() call? The "skeleton"
>of the object, only the static part of its structure? What happens after
>that with a method call? An exception?
>

Close() is class specific. Close() on a Statement object releases
any pending result sets, update counts, sql strings, anything pending
particular to its engine. Close() on a Connection returns it to
unconnected state.

>
>> All objects are automatically closed, if necessary, prior to
>> deletion.
>
>
> I can't agree more, of course.
>
>
>> A parent object, when deleted, takes its children with it. Releasing
>> a PreparedStatement would automatically delete all ResultSets. Releasing
>> a Connection object would delete everything associated with the
>> connection.
>
>
>> I will also redefine release() to return the post release use
>> count of the object. A return of zero means the object is history.
>
>This is common practice in several libraries. What happen if release() is
>called when the internal count is zero? Exception? Undefined?
>

Unpredicatably bad. Never good or even benign.

>
>> A client that wants to force release must loop decrementing the
>> use count to zero.
>
>Can I mix close() and release(), then? AFAIK, after calling close(), the
>component is almost gone, so the release() work is decrementing the counter
>mainly.
>

Yes.


Jim Starkey