On 8 October 2012 13:41, Henrik Sperre Johansen
<[email protected]> wrote:
> On 08.10.2012 13:25, Igor Stasenko wrote:
>>
>> On 8 October 2012 13:06, Henrik Sperre Johansen
>> <[email protected]> wrote:
>>>
>>> On 08.10.2012 13:03, Henrik Sperre Johansen wrote:
>>>>
>>>>
>>>>
>>>> IMO, lazily checking whether the image has been restarted whenever you
>>>> want to do something stinks.
>>>> Registering to be notified when image starts/stops is a lot better.
>>>
>>> Not to mention, less error-prone.
>>> Miss one session check that the current session is the right one
>>> somewhere... and everything might blow up if that is the first piece of
>>> functionality used.
>>>
>> True.
>> I did not said that my method should replace old. Sometimes lazy
>> initialization is not what you want.
>> But having no way to perform lazy initialization is even worse.
>
> Ah, I just objected to the notion that startup lists inherently stinks, and
> took the diametrical view for the sake of argument :)
> Yes, lazy initialization has its uses too, but some guidelines/advice* on
> when to what those uses are, and when you'd use startUp: registration
> instead, is needed I think.
>
> Notice; in most cases where such cleanup at startup is needed (sockets,
> window handles, etc.), additional cleanup is needed when the object goes out
> of scope during regular use, and so a registry usually exist.

Yes.

> Thus, your startup code isn't usually
> X allInstancesDo: #something
> but
> X weakRegistry allEntriesDo: #someting.
>
> which stinks a whole lot less.
>
in perfect world, yes :)

But world is imperfect..
For example, look here:

FT2Handle>>shutDown: quitting
        "we must not save handles (which are pointers) in the image"
        self clearRegistry.
        FreeTypeFace allInstances do:[:i |
                "destroy any faces that are still being referenced"
                i isValid
                        ifTrue:[i destroyHandle]].
        FT2Handle allSubInstances do: [:h | h beNull].  "if some handle was
not registered"

because of the above, when i pass freetype faces handles to Cairo,
which caching a lot of stuff inside (obviously for performance reasons),
when you save an image, and then try to use Cairo after that (like
rendering text with same font)
an image is crashing.
Which means that "we must not save handles (which are pointers) in the
image" now blocking
me from having nice interoperability with Cairo..

Needless to say that destroying handles will force their recreation
after snapshot, since image
continues running and will keep using freetype fonts.

This is actually the reason why i want to introduce session object(s),
so that i can fix freetype code
to play more nicely with cairo library.


> Cheers,
> Henry
>
>
> *So in my view, to use lazy init over startUp registration, it would need
> to:
> - Concern instance data.
> - Not need weak cleanup.
> - Be containable to a single accessor
>



-- 
Best regards,
Igor Stasenko.

Reply via email to